-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_1.cpp
58 lines (55 loc) · 954 Bytes
/
6_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "iostream"
using namespace std;
class Time
{
int hr, min, sec;
public:
void getdata();
void putdata();
Time()
{
cout << "defaut constructor ";
hr = 0;
min = 0;
sec = 0;
}
Time(int h, int m, int s = 52)
{
cout << "parameterized constructor " << endl;
hr = h;
min = m;
sec = s;
}
// Time(Time &t)
// {
// cout << "copy constructor " << endl;
// hr = t.hr;
// min = t.min;
// sec = t.sec;
// }
~Time()
{
cout << "destructor called" << endl;
}
};
void Time::getdata()
{
cout << "enter hour min and sec" << endl;
cin >> hr >> min >> sec;
}
void Time ::putdata()
{
cout << hr << ":" << min << ":" << sec << endl;
}
int main()
{
Time t1;
t1.putdata();
Time t2(5, 7);
t2.putdata();
Time t3(t2);
t3.putdata();
Time t4;
t4 = t2;
return 0;
}