河南成教 / 面向对象程序设计
24[分析题]
#include “iostream.h” #include “stdio.h”class timer{ //定义一个时间类int seconds;public:timer();{ seconds=0; }timer(int x){ seconds=x; } timer(int min,int sec){seconds=min*60 sec;}int gettime(){return seconds;}};main(){ timer a, b(10),c(1,10); cout<<a.gettime()<<’endl; cout<<b.gettime()<<endl; cout<<c.gettime()<<endl; return 0;}
24[分析题]
#include “iostream.h” #include “stdio.h”class timer{ //定义一个时间类int seconds;public:timer();{ seconds=0; }timer(int x){ seconds=x; } timer(int min,int sec){seconds=min*60 sec;}int gettime(){return seconds;}};main(){ timer a, b(10),c(1,10); cout<<a.gettime()<<’endl; cout<<b.gettime()<<endl; cout<<c.gettime()<<endl; return 0;}
参考答案:
佳题速递: