An extract from Operator overloading
I strongly advise you to read the above as its well written
Operators for Pointer-like Types
For defining your own iterators or smart pointers, you have to overload the unary prefix > dereference operator * and the binary infix pointer member access operator ->:
class my_ptr {
value_type& operator*();
const value_type& operator*() const;
value_type* operator->();
const value_type* operator->() const;
};
Note that these, too, will almost always need both a const and a non-const version. For >the -> operator value_type must be of class (or struct or union) type, otherwise their >implementation results in a compile-time error.
The unary address-of operator should never be overloaded.
For operator->*() see this question. It's rarely used and thus rarely ever overloaded. In >fact, even iterators do not overload it.