MCPcopy Create free account
hub / github.com/EricPengShuai/Interview / main

Function main

base_code/overload.cpp:63–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63int main() {
64 Time t1(12,10,11);
65 t1.ShowTime();
66
67 cout << "reload () method1:\n";
68 // 第一种写法
69 t1.operator()(23,20,34);
70 t1.ShowTime();
71
72 cout << "reload () method2:\n";
73 // 第二种写法
74 t1(10,10,10);
75 t1.ShowTime();
76 cout << endl;
77
78 cout << "reload = method:\n";
79 Time t2;
80 t2 = t1;
81 t2.ShowTime();
82 cout << endl;
83
84 cout << "reload [] method:\n";
85 int a = t2[1];
86 int b = t2["abcd"];
87 cout << "a=" << a << endl;
88 cout << "b=" << b << endl << endl;
89
90 cout << "reload --t and t--:\n";
91 -- t2;
92 t2.ShowTime();
93 t2 --;
94 t2.ShowTime();
95 cout << endl;
96
97 cout << "reload + and -:\n";
98 Time t3 = t1 + t2;
99 t3.ShowTime();
100 Time t4 = t1 - t2;
101 t4.ShowTime();
102 return 0;
103}
104

Callers

nothing calls this directly

Calls 3

t1Function · 0.85
ShowTimeMethod · 0.80
operator()Method · 0.45

Tested by

no test coverage detected