办法:先承继类然后映射函数。
#include
class animal
{
public:
animal(char thename);
};
animal::animal(char thename)
{
char name;
cout<
class pig:public animal //先承继类,并在次写上子类映射函数
{
public:
pig(char thename);
};
pig::pig(char thename):animal(thename) //后映射函数。留意父类函数此刻无需再界说数据类型
{
}
class turtle:public animal
{
public:
turtle(char thename);
};
turtle::turtle(char thename):animal(thename)
{
}
int main()
{
pig st(M);
turtle sm(n);
return 0;
}