⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 302b.cpp

📁 C++实训教程
💻 CPP
字号:
/*	302b.cpp	Written By S.Y.Feng	demo a simple Time class
with a default constructor 
The default constructor for class X is one 
that takes no arguments;
it usually has the form X::X().
If no user-defined constructors exist for a class,
C++ system generates a default constructor.
*/
#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;
		t1.Disp();
		t1.Set(2,22,22);		t1.Disp();
		return 0;
}

/*
The time is 4225416:4238172:1
The time is 2:22:22


*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -