Possible Duplicate:
How to resolve “LINK : fatal error LNK1561: entry point must be defined”?C++串倍率联错误
我有类A和B是这样并且在连接有错误:错误LNK1561:入口点必须被定义。我究竟做错了什么?
#include <string>
#include <cstdlib>
class A
{
public:
A(){}
~A(){}
string getName()
{ return name; }
void setName(string name)
{this->name = name;}
void write()
{
cout << "Value:" << getName() << endl;
}
protected:
string name;
};
#include <string>
#include "A.h"
class B : public A
{
public:
B()
{
setName("B");
}
~B(){}
};
#include "A.h"
#include "B.h"
#include <cstdlib>
int main()
{
B abc = B();
abc.write();
system("PAUSE");
return 0;
}
我收到以下错误:
错误C2039: '名':是不是 'A'
错误C2061的成员:语法错误:标识符 '串'
错误C2065:COUT ':未声明的标识符
错误C2065:ENDL':未声明的标识符
错误C2065:名称:未声明的标识符
错误C2146:语法错误:缺少 ';'在标识符'getName'之前
错误C2146:语法错误:缺少';'标识符'name'前
错误C2660:'A :: setName':函数不带1个参数
错误C4430:缺少类型说明符 - 假定为int。注意:C++不支持default-int
欢迎来到Stack Overflow!在提出新问题之前请使用搜索。很多问题已经被提出并得到解答,您可能会立即找到解决方案。 – 2011-04-21 17:56:47
您也错过了这个:'using namespace std;' – yasouser 2011-04-21 18:09:28