Triangle triangle(4.5,8.4); //建立Triangle类对象 Shape *pt[5]={&circle,&square,&rectangle,&trapezoid,&triangle};
//定义基类指针数组pt,使它每一个元素指向一个派生类对象
double areas=0.0; //areas为总面积 for(int i=0;i<5;i++)
{areas=areas+pt[i]->area();}
cout<<\ //输出总面积 return 0; }