预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共33页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

第6章2346.1多态性6.1多态性6.1多态性6.1多态性例题106.2虚函数6.2虚函数6.2虚函数6.2.3静态关联和动态关联6.2虚函数6.2虚函数6.2虚函数6.2虚函数实验九练习21抽象类引入抽象类引入6.3纯虚函数与抽象类6.3纯虚函数与抽象类6.3纯虚函数与抽象类6.3纯虚函数与抽象类//声明Circle类 classCircle:publicPoint {public: Circle(floatx=0,floaty=0,floatr=0):Point(x,y) {radius=r;} virtualfloatarea()const{return3.14*radius*radius;} virtualvoidshapeName()const{cout<<"Circle:";} protected: floatradius; };classCylinder:publicCircle {public: Cylinder(floatx=0,floaty=0,floatr=0,floath=0): Circle(a,b,r),height(h){} virtualfloatarea()const {return2*Circle::area()+2*3.14*radius*height;} virtualfloatvolume()const {returnCircle::area()*height;} virtualvoidshapeName()const{cout<<"Cylinder";} protected:floatheight; };3233