cfnr.net
当前位置:首页 >> 用C++定义一个时间类timE,编程实现下列功能. >>

用C++定义一个时间类timE,编程实现下列功能.

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...

#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...

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

#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 #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...

#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;class Time{public:Time();Time(int,int,int);~Time();void AddHour(int);void AddMin(int);void AddSec(int);void AddTime(int,int,int);void SubHour(int);void SubMin(int);void SubSec(int);void Sub...

什么语言?

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

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...

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