#include <iostream> using namespace std; class clock { protected: int hr, min, sec ; public: clock() { hr = min = sec = 0; } clock(int x) { hr = min = sec = x ; } void Show(); }; class wall_clock:public clock { int TotalTime; public: wall_clock():clock() { TotalTime = 0 ; } wall_clock(int x):clock(x) { } void Add(int, int, int); void ShowTime(); }; void clock::Show() { cout << endl << "Initially" << endl ; cout << endl << hr << ":" << min << ":" << sec << endl ; } void wall_clock::Add(int a, int b, int c) { hr+=a; min+=b; sec+=c; } void wall_clock::ShowTime() { if(sec>60) { min += sec/60; sec = sec%60; } if(min>60) { hr += min/60 ; min = min%60; } cout << endl << hr << ":" << min << ":" << sec << endl ; } int main() { wall_clock WC1,WC2; WC1 = 0 ; WC2 = 0 ; WC1.Show(); WC2.Show(); WC1.Add(1,17,65); WC2.Add(4,45,49); WC1.ShowTime(); WC2.ShowTime(); return 0; }
C and C++ programs, games, softwares. Easy programming guide. Learn to code and enjoy coding in CoderNepal
Home » OOPL T.U 2067 Q.N. 3
OOPL T.U 2067 Q.N. 3
This is the solution for T.U. 2067 Q.N.3
Subscribe to:
Posts (Atom)
No comments:
Post a Comment