I won't write all the code, but I am looking at a smart pointer example implementation and it has:
template<typename T>
class smart_ptr
{
public:
operator void*() const {return mPtr;}
const T& operator*() const;
T& operator*();
const T* operator->() const;
T* operator->();
private:
T* mPtr;
};
- What is the purpose of the first public function in the API?
- Why do we need to const-overload the other two API methods?
- Not only const-overload, but why have return-const-object variants?