c++03-1.pptVIP

  • 7
  • 0
  • 约1.96万字
  • 约 77页
  • 2016-12-27 发布于重庆
  • 举报
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Object Oriented 第二节 对象的初始化—构造函数与析构函数 #include iostream.h class timer { private: int seconds; public: timer() {seconds=0;} timer(int i) {seconds=i;} timer(int min,int sec) {seconds=min*60+sec;} int gettime() {return seconds;} }; 例【3.14】分析下列程序,熟悉构造函数的重载。 Object Oriented 第二节 对象的初始化—构造函数与析构函数 void main(void) { timer a,b(10),c(1,10); coutseconds1=a.gettime()endl; coutseconds2=b.gettime()endl; coutseconds3=c.gettime()endl; } Object Oriented 第二节 对象的初始化—构造函数与析构函数 五、拷贝构造函数(复制构造函数

文档评论(0)

1亿VIP精品文档

相关文档