302.cpp
来自「C++实训教程」· C++ 代码 · 共 29 行
CPP
29 行
/* 302.cpp Written By S.Y.Feng demo a simple Time class*/
#include <iostream.h>
class Time // define Time class
{
int hh,mm,ss;
public:
Time(){hh=0;mm=0;ss=0;}
void Set(int h, int m, int s) {hh = h; mm = m; ss=s;}
void Disp();
};
void Time::Disp()
{
cout << "The time is " << hh << ":"
<< mm << ":" << ss <<endl;
}
int main()
{
Time t1,t2; //两个对象
t1.Set(1,11,11); t1.Disp();
t2.Set(2,22,22); t2.Disp();
return 0;
}
/* ok
The time is 1:11:11
The time is 2:22:22
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?