Possible Duplicate:
How to convert this code to use string
I have a function like this:
char *foo()
{
}
How can I make it return a string instead? I tried
string foo()
{
}
but the compiler complains.
Possible Duplicate:
How to convert this code to use string
I have a function like this:
char *foo()
{
}
How can I make it return a string instead? I tried
string foo()
{
}
but the compiler complains.
Did you do this:
#include <string>
using std::string;
And additionnally, do you use gcc
or g++
? Even if gcc
now can compile C++ code, it is advised to use g++.
Try std::string. Standard features are in the std:: namespace.
std::string foo()
{
}
Be careful with "using" directives, especially in header files. Better take the habit to use std::