c11.cpp

来自「时钟设置时钟类程序」· C++ 代码 · 共 38 行

CPP
38
字号
//clock.h
#include <iostream.h>
class clock
{
public:
    void settime(int newh=0,int newm=0,int news=0);
    void showtime();
private:
    int hour,minute,second;
	

};
//clock.cpp
void  clock::settime(int newh,int newm,int news)
{
    hour=newh;
    minute=newm;
    second=news;
}

	inline void  clock::showtime()
{
   cout<<hour<<":"<<minute<<":"<<second<<endl;
}

void main()
{
     clock  a;
     cout<<"first time set and output:"<<endl;
     a.settime(7,0,0);        
     a.showtime();
     cout<<"second time set and output:"<<endl;
     a.settime(4,30,20);
     a.showtime();
}


⌨️ 快捷键说明

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