6-4
来源:互联网 发布:线条底纹生成软件 编辑:程序博客网 时间:2024/06/05 05:02
#include <iostream.h>class Shape{public:virtual double area()const =0;};class Circle:public Shape{public:Circle(double r):radius(r){}virtual double area() const{ return 3.1415*radius*radius;}protected:double radius;};class Rectangle :public Shape{public:Rectangle(double l,double w):length(l),width(w){}virtual double area()const{ return length*width;}protected:double length;double width;};class Triangle:public Shape{public:Triangle(double d,double h):dibian(d),height(h){}virtual double area() const{ return 0.5*dibian*height;}protected:double dibian;double height;};void display(const Shape &s){ cout<<s.area()<<endl;}int main(){ Circle c(4); cout<<"area of c is "; display(c); Rectangle r(2,4); cout<<"area of r is "; display(r); Triangle t(1,2); cout<<"area of t is "; display(t); return 0;}
0 0
- 4-6
- 4-6
- 4-6
- 6-4
- 6-4
- 例4-5,4-6
- 东北话4、6级
- 4-6-点滴
- 2007-6-4
- 4月6日
- 2008-6-4
- python challenge 4-6
- 4-6教育
- CCNA 4 Chapter 6
- 实验报告6------4
- 2012-4-6
- Exercises 4-6
- 2012-6-4
- 关于函数strtok和strtok_r的使用要点和实现原理(一)
- linux下etc下resolv.conf文件的作用
- 局域网内mysql连接慢的解决办法
- Tutorial1 Open a window
- mysql服务性能优化—my.cnf配置说明详解(16G内存)
- 6-4
- Tar.gz加密解密总结
- 编译Apache提示:APR 及PCRE 错误
- OpenCart多图片拖放式上传管理器
- 用链表实现两个数相加
- Java套接字2
- 华为2015年实习生招聘考试试题
- 有用的代码片段
- lamp环境搭建mysql5.5+httpd2.4+php5.6