Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class time
- {
- private:
- int hours, minutes, seconds;
- public:
- time()
- {
- hours = minutes = seconds = 0;
- }
- time(int h, int m, int s)
- {
- hours = h;
- minutes = m;
- seconds = s;
- }
- int getHours() { return hours; }
- int getMinutes() { return minutes; }
- int getSeconds() { return seconds; }
- void display()
- {
- cout << "Time: " << hours << ":" << minutes << ":" << seconds << endl;
- }
- time operator+(time t)
- {
- time result(hours + t.getHours(), minutes + t.getMinutes(), seconds + t.getSeconds());
- return result;
- }
- time operator-(time t)
- {
- time test(hours - t.getHours(), minutes - t.getMinutes(), seconds - t.getSeconds());
- return test;
- }
- time operator*(time t)
- {
- time test1(hours * t.getHours(), minutes * t.getMinutes(), seconds * t.getSeconds());
- return test1;
- }
- };
- int main()
- {
- time a(5, 25, 34);
- time b(3, 24, 10);
- time result = a + b;
- result.display();
- time test = a - b;
- test.display();
- time test1= result * test;
- test1.display();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement