2011-11-27 105 views
1

我是新来的C++,我通常可以挑选错误并找出错误,但我很难过。编译错误:不会命名一个类型

我得到一个错误说 “行| 10 |错误:在课堂上 '我的' 没有指定类型 '字符串'”

这里是mine.h:

#ifndef MINE_H 
#define MINE_H 
#include <iostream> 
#include <string> 

using namespace std; 

class mine 
{ 

public: 
mine(); 
string getName(); 

}; 

#endif // MINE_H 

这里是mine.cpp:

#include "mine.h" 
#include <iostream> 
#include <string> 

using namespace std; 
mine::mine() 
{ 
    //ctor 
} 

mine::string getName() 
{ 

} 
+2

请不要使用'使用namespace'。 – GManNickG

+1

而**从不**(ab)在头文件中使用'namespace std'! –

回答

7
mine::string getName() 
{ 

} 

本来应该

string mine::getName() 
{ 

} 
+0

谢谢你,修复它 – user1068454

3

它应该是:

string mine::getName() 
{ 

}