-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
52 lines (37 loc) · 821 Bytes
/
main.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
#include <iostream>
using namespace std;
class Cents
{
private:
int m_cents {};
public:
Cents(int cents) { m_cents = cents; }
explicit Cents(int c1, int c2){ c1 =0; c2=0; }
int getCents() const { return m_cents; }
// friend Cents operator+(const Cents &c1, int value);
// friend Cents operator+(int value, const Cents &c1);
};
Cents operator+(Cents const &lhs, int v)
{
return (Cents(lhs.getCents() + v));
}
Cents operator+(int v, Cents const &rhs)
{
return (Cents(v+ rhs.getCents()));
}
void func(int, int)
{
std::cout << "Yaaaxy!"<< std::endl;
}
int main()
{
int *value = new (std::nothrow) int;
*value = 10;
cout << *value << endl;
Cents c1(10);
Cents c2(20);
Cents c3 = 6 + c2;
cout << c3.getCents() << endl;
func(10, 11);
return 0;
}