C++ day7 - 指南
#include
using namespace std;
class Animal
{
public:
virtual void perform()=0;
virtual ~Animal(){}
};
class Lion:public Animal
{
private:
string food;
string action;
public:
Lion(string food,string action):food(food),action(action){}
void perform()
{
coutperform();
Elepthent elepthent("土","洗澡");
Animal *p1=&elepthent;
p1->perform();
Moneky moneky("桃子","爬树");
Animal *p2=&moneky;
p2->perform();
delete p;
delete p1;
delete p2;
p=nullptr;
p1=nullptr;
p2=nullptr;
return 0;
}