#include <iostream>
using std::cout;
using std::cin;
using std::endl;
class Time {
public:
Time() :h(0), m(0), s(0) {}
Time(int s_) :Time() {
s = s_;
}
Time(int m_, int s_) :Time(s_) {
m = m_;
}
Time(int h_, int m_, int s_) : Time(m_, s_) {
h = h_;
}
//private:
int h;
int m;
int s;
};
int main()
{
Time t1;
Time t2(5);
Time t3(3, 16);
Time t4(10, 20, 15);
cout << "t1 : " << t1.h << " : " << t1.m << " : " << t1.s << endl;
cout << "t2 : " << t2.h << " : " << t2.m << " : " << t2.s << endl;
cout << "t3 : " << t3.h << " : " << t3.m << " : " << t3.s << endl;
cout << "t4 : " << t4.h << " : " << t4.m << " : " << t4.s << endl;
}
더보기
t1 : 0 : 0 : 0
t2 : 0 : 0 : 5
t3 : 0 : 3 : 16
t4 : 10 : 20 : 15
'C,C++' 카테고리의 다른 글
C,C++ : 구조체 만들기(struct) (0) | 2023.07.31 |
---|---|
C,C++ : typedef 자료형에(구조체) 새 이름(별명) (0) | 2023.07.31 |
C/C++ 초기화 (0) | 2023.07.26 |
C,C++: 글래스 구초체 (0) | 2023.07.26 |
C,C++ : using, namespace(std::cout,std::endl) (0) | 2023.07.19 |