string’ does not name a type 错误解析
生活随笔
收集整理的這篇文章主要介紹了
string’ does not name a type 错误解析
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
‘string’ does not name a type 今天寫(xiě)代碼有一次遇見(jiàn)這錯(cuò)誤!雖然不是第一次遇見(jiàn)了,但還是耽誤了一小會(huì),為了不再耽誤時(shí)間,所以把錯(cuò)誤寫(xiě)下
?
示例理解:
| ? | #ifndef EMP_H #define EMP_H #include <string> struct menuEntry { string uID; //error: 'string' does not name a type string uName; //error: 'string' does not name a type }; #endif//EMP_H |
?
| ? | #ifndef EMP_H #define EMP_H #include <string> struct menuEntry { std::string uID; /* ok */ std::string uName; /* ok */ }; #endif//EMP_H |
也可以直接加上命名空間 using namespace std;
別忘了包含頭文件<string>
總結(jié)
以上是生活随笔為你收集整理的string’ does not name a type 错误解析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: const_cast的使用:添加或去掉c
- 下一篇: 内联函数的定义可能不止一次