全文预览

C 编程题库(一)

上传者:学习一点 |  格式:pdf  |  页数:61 |  大小:6722KB

文档介绍
radius;\r)´\rclass Rectangle:public Shape\r{public:\rRectangle(double w,double h):width(w), height(h){}\rvirtual double area() const {return width*height;}\rprotected:\rdouble width, height;\r)´\rclass Triangle:public Shape\r{public:\rTriangle(double w, double h):width(w), height(h){}\rvirtual double area() const {return 0. 5*width*height;}\rprotected:\rdouble width, height;\r)´\rvoid printArea(const Shape &s).\r{cout<<s. area () <<endl;}\rint main()\r(\rCircle circle (12. 6);\rcout<<zarea of circle = P\rprintArea(circle);\rRectangle rectangle (4. 5, 8. 4);\rcout<<area of rectangle 0 P\rprintArea(rectangle);\rTriangle triangle (4. 5, 8. 4);\rcout<<zarea of triangle 0 P\rprintArea(triangle);\rreturn 0;

收藏

分享

举报
下载此文档