hi guys
i have a little question
i don't understand this line
typedef basic_string <char> string ;
i have searched but can't get it any one can help
ur help will be appreciated

>i don't understand this line typedef basic_string <char> string;

basic_string class is parameterized by character type. There is no need to use the basic_string template directly. The types string and wstring are typedefs for, respectively, basic_string<char> and basic_string<wchar_t>.

See article.

That line is basically creating a new variable type for you called string, the basic_string<char> is something you dont need to worry about, I will just guess though that you included <string> into your program. string is just another way of saying char*, but it is less of an array and more of a vector, at least in my opinion ;). With that line, now you can make something like this:

string mystring = "HelloWorld!\n";
cout << mystring;

Hope that was helpful

- Pranav Sathyanarayanan

thanks adatapost and WargRider so much
but the question is about basic string<char>
i am not professional in c++
but all my knowledge
was that we can write typedef int integer
something like this
i know basic string is a class but why we didn't write it in this way

basic_string (char)
and thanks again ur posts were so helpful guys : )

Do you know what this means :

typedef unsigned int uInt //?

Do you know what a class is?

Then all this

typedef basic_string <char> string

is, is a typedef for a template class called basic_string;

Its the same as this :

typedef int INT

in concept, but instead of int they substitute it for a template class.

commented: Helpful! +7
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.