📄 3.9.txt
字号:
例3.9
#include <iostream.h>
#include <stdlib.h>
class timer{
int seconds;
public:
timer() //无参构造函数,给seconds清零
{ seconds=0;}
timer(char *t) //含一个数字串参数的构造函数
{ seconds=atoi(t); }
timer(int t) //含一个整型参数的构造函数
{ seconds=t; }
timer(int min,int sec) //含两个整型参数的构造函数
{ seconds=min*60+sec; }
int gettime()
{ return seconds; }
};
void main()
{
timer a,b(10),c("20"),d(1,10);
cout<<"seconds1="<<a.gettime()<<endl;
cout<<"seconds2="<<b.gettime()<<endl;
cout<<"seconds3="<<c.gettime()<<endl;
cout<<"seconds4="<<d.gettime()<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -