‘string’ does not name a type 错误解析

‘string’ does not name a type 今天写代码有一次遇见这错误!虽然不是第一次遇见了,但还是耽误了一小会,为了不再耽误时间,所以把错误写下

示例理解:

#ifndef EMP_H 
#define EMP_H 
#include  
 
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  
 
struct menuEntry  
{  
    std::string uID;      /* ok */       
    std::string uName;    /* ok */
 }; 
 
#endif//EMP_H

也可以直接加上命名空间 using namespace std;

别忘了包含头文件

你可能感兴趣的:(before,the,2015)