#include<iostream>
using namespace std;
class Pet
{
public:
	virtual void function()
	{
		cout<<"Pet::function"<<endl;
	}
};
class Dog:public Pet
{
public:
	void function()                      //对于虚函数的重写，不需要重复声明virtual
	{
		cout<<"Dog::function"<<endl;
	}
};
int main()
{
	Pet* point;
	Pet a;
	Dog b;
	point=&a;
	point->function();
	point=&b;
	point->function();
	return 0;
}