请C++高手帮我想想,谢谢老师!

2024-10-31 13:26:41
有1个网友回答
网友(1):

#include "windows.h"

class Animal
{
public:
Animal(){}
~Animal(){}

public:

virtual void eat()
{

}
};

class fish : public Animal
{
public:
fish(){}
~fish(){}

public:

void eat()
{

}

void operator << (int nCount)
{
m_count = nCount;
}

private:

int m_count;
};

class Human
{
friend class fish;

public:

Human(){}
~Human(){}

void eat()
{

}
};

class Children : public Animal, public Human
{
public:
Children(){}
~Children(){}

public:
void eat()
{

}
};

int main( int nArgc, char** pArgv )
{
Children* pChild = new Children;

pChild->eat();

delete pChild;

fish pFish;
pFish<<10;

return 0;
}