1// money.h -- define the prototype
2class Money
3{
4 public:
5 Money & operator += (const Money &rhs);
6}
7
8// money.cpp -- define the implementation
9Money& Money :: operator += (const Money &rhs)
10{
11 // Yadda Yadda
12
13 return *this;
14}
1// This will substract one vector (math vector) from another
2// Good example of how to use operator overloading
3
4vec2 operator - (vec2 const &other) {
5 return vec2(x - other.x, y - other.y);
6}
1class Point
2{
3public:
4 Point& operator++() { ... } // prefix
5 Point operator++(int) { ... } // postfix
6 friend Point& operator++(Point &p); // friend prefix
7 friend Point operator++(Point &p, int); // friend postfix
8 // in Microsoft Docs written "friend Point& operator++(Point &p, int);"
9};
10