#include <iostream> using namespace std;
class Cat;
class Fish
{public:
Fish(int w):weight(w){}
virtual void getexp(Cat&c){}
protected:
int weight;
};
class Cat
{ public:
Cat(int l,int e):level(l),exp(e){}
void CatchFish(Fish&ff);
public:
int level;
int exp;
};
class Octopus:public Fish
{
public:
Octopus(int w):Fish(w){}
void getexp(Cat&c )
{
c.exp+=2*weight;
}
};
void Cat::CatchFish(Fish&ff)
{
ff.getexp(this);
Levelup();
}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
老是这个错误!!为什么呀~~
F:\cc++\catchatchfish\main.cpp||In member function 'void Cat::CatchFish(Fish&)':|
F:\cc++\catchatchfish\main.cpp|71|error: no matching function for call to 'Fish::getexp(Cat* const)'|
F:\cc++\catchatchfish\main.cpp|8|note: candidates are: virtual void Fish::getexp(Cat&)|
||=== 已完成构建: 1 个错误, 0 个警告 ===|
class Cat;
class Fish
{public:
Fish(int w):weight(w){}
virtual void getexp(Cat&c){}
protected:
int weight;
};
class Cat
{ public:
Cat(int l,int e):level(l),exp(e){}
void CatchFish(Fish&ff);
public:
int level;
int exp;
};
class Octopus:public Fish
{
public:
Octopus(int w):Fish(w){}
void getexp(Cat&c )
{
c.exp+=2*weight;
}
};
void Cat::CatchFish(Fish&ff)
{
ff.getexp(this);
Levelup();
}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
老是这个错误!!为什么呀~~
F:\cc++\catchatchfish\main.cpp||In member function 'void Cat::CatchFish(Fish&)':|
F:\cc++\catchatchfish\main.cpp|71|error: no matching function for call to 'Fish::getexp(Cat* const)'|
F:\cc++\catchatchfish\main.cpp|8|note: candidates are: virtual void Fish::getexp(Cat&)|
||=== 已完成构建: 1 个错误, 0 个警告 ===|