【发布时间】:2012-01-07 13:30:00
【问题描述】:
我是 C++ 新手,我通常可以找出错误并找出问题所在,但我很困惑。
我收到一条错误消息“line|10|error: 'string' in class 'mine' does not name a type”
这是我的.h:
#ifndef MINE_H
#define MINE_H
#include <iostream>
#include <string>
using namespace std;
class mine
{
public:
mine();
string getName();
};
#endif // MINE_H
这是我的.cpp:
#include "mine.h"
#include <iostream>
#include <string>
using namespace std;
mine::mine()
{
//ctor
}
mine::string getName()
{
}
【问题讨论】:
-
请不要使用
using namespace。 -
并且从不(ab)在头文件中使用
namespace std!