马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<iostream>
#include<string>
class Pet
{
public:
Pet(std::string thename);
void FREE_TEST();
void FOOK_TEST();
void EAT_TEST();
protected:
std::string name;
};
class dog:public Pet
{
public:
dog(std::string thename);
void CLIMB();
};
class cat:public Pet
{
public:
cat(std::string thename);
void KIDDING_TEST();
};
Pet::Pet(std::string thename)
{
name = thename;
}
void Pet::FREE_TEST()
{
std::cout<<name <<"\n"<<"FREE TEST OK"<<std::endl;
}
void Pet::FOOK_TEST()
{
std::cout<<name <<"FOOK TEST OK"<<std::endl;
}
void Pet::EAT_TEST()
{
std::cout<<name <<"EAT TEST OK "<<std::endl;
}
dog::dog(std::string thename):Pet(thename)
{
}
void dog::CLIMB()
{
std::cout<<"CLIIMB TEST OK"<<std::endl;
}
cat::cat(std::string thename):Pet(thename)
{
}
void cat::KIDDING_TEST()
{
std::cout<<"KIDDING TEST OK "<<std::endl;
}
int main()
{
Pet *dog = new dog("123");
Pet *cat = new cat("546456");
//dog->CLIMB();
//dogFREE_TEST();
//dog.FOOK_TEST();
//dog.EAT_TEST();
//cat->KIDDING_TEST();
//cat.FREE_TEST();
//cat.EAT_TEST();
//cat.FOOK_TEST();
return 0;
}
最后编译提示 dog和cat 不是一个type
本人愚笨,还请各位大神指教 |