vc++编c++程序,编译时没错,连接时出错

来源:百度知道 编辑:UC知道 时间:2024/05/31 21:01:18
linking下写着:
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall fish::eat(void)" (?eat@fish@@QAEHXZ)

Debug/animal main.exe : fatal error LNK1120: 1 unresolved externals

是我的代码没写好还是软件或系统的问题?急死我了
代码是如下,大家能不能指明我到底哪行错了,怎么改,多谢了:
#include <iostream.h>

class animal
{
public:
animal(int height,int weight);
void eat();
virtual void breathe();
virtual void sleep()=0;
};

animal::animal(int height,int weight)
{
cout<<"its height is "<<height<<endl;
cout<<"its weight is "<<weight<<endl;
};
void animal::eat()
{
cout<<"eat with mouth"<<endl;
};
void animal::breathe()
{
cout<<"breathe with lung"<<endl;
};

class fish:public animal
{
public:
fish(int

你还少一个实现函数

void fish::eat()
{
cout<<"fish with mouth"<<endl;
};

是主程序头出了问题,你把代码全部给我我来帮你

unresolved external symbol "public: int __thiscall fish::eat(void)" 意思是类中fish没有在主函数中调用.

fish类中声明的eat方法没有实现

eat函数没有定义