#include<iostream>usingnamespace std;classShape{public:virtualvoiddraw(){
cout <<"This is a generic shape."<< endl;}};classCircle:publicShape{public:voiddraw(){
cout <<"This is a circle."<< endl;}};classSquare:publicShape{public:voiddraw(){
cout <<"This is a square."<< endl;}};intmain(){
Shape* shape;
Circle circle;
Square square;
shape =&circle;
shape->draw();// 输出 "This is a circle."
shape =□
shape->draw();// 输出 "This is a square." return0;}