-
Notifications
You must be signed in to change notification settings - Fork 0
/
optimizer_pwnage.cpp
41 lines (34 loc) · 1009 Bytes
/
optimizer_pwnage.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
#include <iostream>
using namespace std;
class Time {
int hours;
int mins;
public:
Time() { hours = 0; mins = 0; cout << "I just created a time at "<< (void*)this << endl; }
Time(const Time& t) { hours = t.hours; mins = t.mins; cout << "copy " << (void*)&t << " to "<< (void*)this << endl; }
~Time() {cout << "I just destroyed a time at " << (void*)this << endl;};
Time add(Time);
};
Time Time::add(Time t) {
Time result;
result.hours = 0;
result.mins = mins + t.mins;
if (result.mins > 60)
{
result.mins -= 60;
result.hours += 1;
}
result.hours += hours + t.hours;
cout << "param is at " << (void*)&t << endl;
cout << "result is at " << (void*)&result << endl;
return result;
}
int main(void) {
Time t;
Time tt;
Time ttt = t.add(tt);
cout << "t is at " << (void*)&t << endl;
cout << "tt is at " << (void*)&tt << endl;
cout << "ttt is at " << (void*)&ttt << endl;
return 0;
}