ex0301.cpp
来自「Visual+C+++6[1].0实用教程代码 Visual+C+++6[1]」· C++ 代码 · 共 39 行
CPP
39 行
// ex0301.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
class Time
{
public:
Time();
void setTime(int,int,int);
void printTime();
private:
int hour;
int minute;
int second;
};
Time::Time() {
hour=minute=second=0;
}
void Time::setTime(int h,int m,int s)
{
hour=(h>=0&&h<24)?h:0;
minute=(m>=0&&m<60)?m:0;
second=(s>=0&&s<60)?s:0;
}
void Time::printTime() {
cout << hour << ":" << minute << ":" << second;
}
int main(int argc, char* argv[])
{
Time t;
t.setTime(20,8,8);
cout << "时间是:";
t.printTime();
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?