开发者

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

开发者 https://www.devze.com 2023-02-09 09:39 出处:网络
#ifndef STRCUTS_H #define STRCUTS_H #include <string> struct menuEntry { string itemID;//\'string\' 开发者_Go百科does not name 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

精彩评论

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