<string> in header file

c++, header, string

Solution

`string` lives in namespace `std`. Make that:

#include <string>

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

Problem

I`m trying to define a variable of string type in a class definition in a header file. Is it possible? Example: ``` /* 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.

Original source