cfnr.net
当前位置:首页 >> 用C++编写一个时间类,通过sEt和gEt的方法,对时间... >>

用C++编写一个时间类,通过sEt和gEt的方法,对时间...

#include #include class CTime{private: tm t; public:CTime(){ time_t tc; time(&tc); t=*localtime(&tc); // printf("\n%s\n",asctime(&t)); } // CTime() virtual ~CTime(){} public:char*get(){ return asctime(&t); }; void set(int* tr){...

你看行不行: #include #include using namespace std;//Time.hclass Time{ private: int hour; int minute; int second; public: Time(int h=0, int m=0,int s=0); void setHour(int h=0); int getHour(); void setMinute(int m=0); int getMin...

class CTime { private : int hour; int min; int sec; public : void set(int h, int m, int s); void set(); void display(); }; void CTime::set(int h, int m, int s) { hour = h; min = m; sec = s; } void CTime::set() { int h,m,s; cout...

定义的是时间类,不是日期类。我做了一些调整,看看能否满足你的需求。还有取时钟,分钟,秒钟我改成了返回时钟,分钟,秒钟值,这样合理一些。 class Time{ int Hour; int Minute; int Second; public: void GetTime()//取时间:格式为08:30:00 ...

第一种方法: class Time { public: int hour; int minute; int second; } 第二种方法: class Time { private: int hour; int minute; int second; public: void print() { cout

#include#include#includeusing namespace std;class Time{public:Time() :h(0), m(0), s(0){}Time(int newh, int newm, int news) :h(newh), m(newm), s(news){}int geth(){ return h; }int getm(){ return m; }int gets(){ return s; }void se...

#include using namespcae std; class time { pubilc: Time(int h, int m, int s); void SetHour(int h); void SetMin(int m); void SetSec(int s); void OutPutTime(); private: int hour; int min; int sec; } Time::Time(int h, int m, int s...

#include using namespace std;class time{ int hour; int min; int sec;public: time(int h=0,int m=0,int s=0) { hour=h;min=m;sec=s; } ~time(){} friend time operator+(time t1,time t2); friend time operator-(time t1,time t2); void op...

1:头文件: #include using namespace std; class Time { public: Time(int a,int b, int c); void display(); private: int hour; int min; int sec; }; 2:time.cpp #include #include"time.h" Time::Time(int a,int b,int c) { hour=a; min=b...

#include class Time{ int h, m ,s; public: Time(){h=m=s=0;} Time(int hh, int mm, int ss) { h=hh; m=mm; s=ss; } friend ostream & operatorh>>m>>s; Time t1(h,m,s); cout

网站首页 | 网站地图
All rights reserved Powered by www.cfnr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com