string’ does not name a type 错误解析
生活随笔
收集整理的這篇文章主要介紹了
string’ does not name a type 错误解析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
‘string’ does not name a type 今天寫代碼有一次遇見這錯誤!雖然不是第一次遇見了,但還是耽誤了一小會,為了不再耽誤時間,所以把錯誤寫下
?
示例理解:
| ? | #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>
總結
以上是生活随笔為你收集整理的string’ does not name a type 错误解析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: const_cast的使用:添加或去掉c
- 下一篇: [C/C++] constexpr函数