3-9.txt

来自「思路很清晰的c++课件。例子很简明」· 文本 代码 · 共 27 行

TXT
27
字号
#include <iostream.h>
#include <stdlib.h>
class timer{
	int seconds;
public:
	timer(){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 + =
减小字号Ctrl + -
显示快捷键?