Bogdan Maier Bogdan Maier - 4 months ago 13
C++ Question

<string> in header file

I`m trying to define a variable of string type in a class definition in a header file. Is it possible?

/* Foo.h */
#include <string>
class Foobar{
int a;
string foo;


Because somehow in main I can declare a string variable, but in the header it doesn’t recognize my string type.


string lives in namespace std. Make that:

#include <string>

class Foobar {
    int a;
    std::string foo;