Tag Archives: before the 2015

Error resolution of ‘string’ does not name a type

‘string’ does not name a type Although it is not the first time to meet, but still delay for a while, in order not to delay time, so write down the mistake

Example understanding:

#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; using namespace STD;
don't forget to include the header file. string>