#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
‘string’ does not name a type 今天写代码有一次遇见这错误!虽然不是第一次遇见了,但还是耽误了一小会,为了不再耽误时间,所以把错误写下
示例理解:
|
|
|
|
|
|
也可以直接加上命名空间
using namespace std;
别忘了包含头文件<string>
本文解决了在C++中使用string类型时遇到的编译错误'string' does not name a type。通过添加命名空间std或直接使用std::string来解决此问题。

8155

被折叠的 条评论
为什么被折叠?



