Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在头文件的类定义中定义字符串类型的变量。是否可以?例子:
/* Foo.h */ #include <string> class Foobar{ int a; string foo; }
因为在 main 中我可以以某种方式声明一个字符串变量,但在标题中它无法识别我的字符串类型。
string生活在命名空间中std。做到这一点:
string
std
#include <string> class Foobar { int a; std::string foo; };