C实验四构造函数与析构函数.docxVIP

  • 12
  • 0
  • 约6.71千字
  • 约 10页
  • 2019-09-14 发布于广东
  • 举报
年 月 日 说明:指导教师评分后,实验报告交院(系)办公室保存。 实验4、构造函数与析构函数 实习目的及要求 掌握构造函数和析构函数定义方法; 掌握构造函数的重载、具有默认值的构造函数的使用方法; 加深对构造函数的特殊用途的理解。 实验内容: 2?1分析下面的程序,按各题要求进行实验 分析下面的程序,指出程序运行的结果: # includeiostream.h class Cylinder { public: Cylinder(){ } Cylinder(double r , double h); void setcylinder(double r .double h); double getradius(){return radius;} double getheight(){ return height;} double volume(); double surface_area(); private: double radius; double height; }; const double PI=3.1415926; Cylinder:: Cylinder(double r , double h) { radius=r; height=h ; } void Cylinder::setcylinder(double r ,double h) radius=r; height

文档评论(0)

1亿VIP精品文档

相关文档