What would be the difference between something like

int func1 = "This is my function"

and

string func = "This is my function" (sorry if syntax is off)

The only thing ive been able to find in research, is that c++ offers a specific header to handle string i/o etc...

thanks

int is a type built right into the language, which means you don't need to link with a library to use it. string (or std::string, to be specific) is a class in the standard library that gives you a string type. Ultimately the difference is minimal, aside from the fact that the two types are used completely differently, of course. ;) But to use std::string, you need to include <string>.

>int func1 = "This is my function"
This is a syntax error, by the way.

lol, ok. Syntax aside =P, you say that the difference is minimal, but the two are usually used in two completly different ways. That confuses me =(. Is the main significance with using the string class the i/o functionality then? And could you possibly throw me some examples different situations when a variable is used and when a string is used?

Thanks again
-the noob

>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion. What I mean is that std::string can be used as a first-class type just like int. However, because they're different types, they have different usage patterns.

>Is the main significance with using the string class the i/o functionality then?
Nope, the significance of using the string class is being able to use strings. :icon_rolleyes: The significance of int is that you can do integer math, which is somewhat more difficult using strings. I/O works with both, fortunately.

commented: rofl +1

>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.

My god, i will live by these words...

Looks like i have some quesi specifics to investigate! Up Up And AWAY!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.