c++day6

c++day6_第1张图片

#include 

using namespace std;
class Animal
{
public:
    virtual void peform() = 0;
};
class Monekey:public Animal
{
public:
   void peform()
   {
       cout << "猴子黑桃A"  << endl;
   }
};
class Elepthant:public Animal
{
    void peform()
    {
        cout << "大象鼻子握手" << endl;
    }
};
int main()
{
   Monekey m;
   Animal *p;
   p = &m;
   p->peform();
   Elepthant e;
   p= &e;
   p->peform();

    return 0;
}

c++day6_第2张图片

你可能感兴趣的:(c++,开发语言)