I am trying to understand this code (it is taken from here ):
template <class T> class auto_ptr
{
T* ptr;
public:
explicit auto_ptr(T* p = 0) : ptr(p) {}
~auto_ptr() {delete ptr;}
T& operator*() {return *ptr;}
T* operator->() {return ptr;}
};
I have a problem with understanding this line of code: explicit auto_ptr(T* p = 0) : ptr(p) {}.
As far as I understand, with this line we are trying to define a constructor with one type argument pointer-to-object-of-T-class. Then we have = 0. What is it? Is this the default value? But how 0can it be the default value for a pointer (the pointer should have addresses as values, not integer ones).
Roman source
share