Learn C++ step by step(2) (轉)
// using Dev C++ under
#include
#include
using namespace std; //standard c++ style about namespace
//define ADT Time
class Time
{
public:
Time(); //default constructor
void setTime(int,int,int);//set time for hours,minutes,seconds
void printMilitary(void);//print time using army's style
void printStandard(void);//print time using standart style
private:
int hour; //0-23
int minute;//0-59
int second;//0-59
};
//constructor Time() initionalize every variable to 0
Time::Time(void)
{
hour=minute=second=0;
}
//set time
void Time::setTime(int h,int m,int s)
{
hour=(h>=0&&h<24)?h:0;
minute=(m>=0&&m<=59)?m:0;
second=(s>=0&&s<=59)?s:0;
}
//print using army's style
void Time::printMilitary(void)
{
cout< < <}
//print using standard style
void Time::printStandard(void)
{
cout< < < <}
//testing for simple class Time
int main(void)
{
Time t;
cout< t.printMilitary();
cout< t.printStandard();
t.setTime(13,27,6);
cout< t.printMilitary();
cout< t.printStandard();
t.setTime(99,99,99);
cout< < t.printMilitary();
cout< t.printStandard();
cout<
system("pause");
return(0);
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-963358/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Learn c++ step by step (轉)C++
- [完結] Learn Vue 2: Step By Step [Laracasts 免費影片中文語音]VueAST
- [完結] Learn Vue 2: Step By Step [Laracasts 免費視訊中文語音]VueAST
- 安裝linux(step by step)(轉)Linux
- ClearCase使用入門--step by step(序) (轉)
- React Step by StepReact
- Oracle 11gR2 Active DataGuard配置Step By Step(一)Oracle
- Oracle 11gR2 Active DataGuard配置Step By Step(二)Oracle
- Oracle 11gR2 Active DataGuard配置Step By Step(三)Oracle
- Command 模式 Step by Step模式
- BAPI Step by step GuidanceAPIGUI
- Step by Step TimesTen --- ttIsqlSQL
- Promise的實現(step by step)Promise
- 轉載一個step by step change public-ip and vip on RAC
- Step by Step TimesTen-- 使用ODBC訪問TimesTen資料庫C++篇(一個例子)(2)資料庫C++
- Step by Step, 為OSRFX2建立一個KMDF驅動程式
- Linux Software RAID step by stepLinuxAI
- Git Step by Step (3):Git物件模型Git物件模型
- Oracle高階複製Step by StepOracle
- 單步除錯 step into/step out/step over 區別詳解除錯
- Oracle 10g R2建立ASM例項Step By Step(一)Oracle 10gASM
- Oracle 10g R2建立ASM例項Step By Step(四)Oracle 10gASM
- ABP應用開發(Step by Step)-下篇
- ABP應用開發(Step by Step)-上篇
- TIDB DM資料同步step by stepTiDB
- Git Step by Step (4):探索.git目錄Git
- Vue.js SSR Step by Step (2) – 一個簡單的同構DEMOVue.js
- Vue.js SSR Step by Step (2) - 一個簡單的同構DEMOVue.js
- Step By Step Install Oracle GC 10.2.0.5 on Redhat Linux 5.5 x86_64 (2/2)OracleGCRedhatLinux
- 實時 Linux 抖動分析 Step by stepLinux
- Git Step by Step (6):Git遠端倉庫Git
- STEP BY STEP INSTALL SSH ON AIX5.3(6.1)AI
- install 11G ASM on RedHat step by stepASMRedhat
- oracle10g simpe AQ step by step(二)Oracle
- oracle10g simpe AQ step by step(一)Oracle
- linux中配置NFS服務step by stepLinuxNFS
- step by step install netbackup client 6.5 on aixclientAI
- Step by Step Data Replication Using Oracle GoldenGateOracleGo