#ifndef STRCUTS_H
#define STRCUTS_H
#include <string>
struct menuEntry
{
string itemID; //'string' does not name a type
string itemName; //'string' does not name a type
};
#endif
当我将#include < string> 放在 header 保护上方时,我得到了同样的错误。想一想,我以前在将结构定义放在标题中时遇到过奇怪的麻烦。一定是我没有得到的东西。
最佳答案
您需要将string
更改为std::string
,即
#ifndef STRCUTS_H
#define STRCUTS_H
#include <string>
struct menuEntry
{
std::string itemID;
std::string itemName;
};
#endif
关于c++ - #include <string> 在 header 中定义了一些结构。错误 : string does not define a type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4931751/