开发者

#include <string> in a header the defines some structs. ERROR: string does not define a type

#ifndef STRCUTS_H
#define STRCUTS_H
#include <string>

struct menuEntry 
{ 
    string itemID;    //'string' 开发者_Go百科does not name a type
    string itemName;  //'string' does not name a type
};

#endif

I get the same error when I put #include < string> above the header guard. Come to think of it, I've had weird trouble with putting struct definitions in headers before. Must be something I'm not getting.


You need to change string to std::string, i.e.

#ifndef STRCUTS_H
#define STRCUTS_H

#include <string>

struct menuEntry 
{ 
    std::string itemID;
    std::string itemName;
};

#endif
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜