M
mathieu
Hi,
I have implemented a SmartPointer class following the implementation
proposed by Bill Hubauer(*). But I also override the operator * ()
template<class ObjectType>
class SmartPointer
{
public:
operator ObjectType * () const
{ return Pointer; }
....
private:
ObjectType* Pointer;
};
Now my compiler can compile:
SmartPointer<Object> s = new Object;
delete s;
Is there a way to prevent that ?
Thanks,
Mathieu
(*)
http://groups.google.com/group/comp.lang.c++/msg/173ddc38a827a930
Full source code is at:
http://svn.sourceforge.net/viewcvs.cgi/gdcm/Source/Common/gdcmSmartPointer.h?view=log
I have implemented a SmartPointer class following the implementation
proposed by Bill Hubauer(*). But I also override the operator * ()
template<class ObjectType>
class SmartPointer
{
public:
operator ObjectType * () const
{ return Pointer; }
....
private:
ObjectType* Pointer;
};
Now my compiler can compile:
SmartPointer<Object> s = new Object;
delete s;
Is there a way to prevent that ?
Thanks,
Mathieu
(*)
http://groups.google.com/group/comp.lang.c++/msg/173ddc38a827a930
Full source code is at:
http://svn.sourceforge.net/viewcvs.cgi/gdcm/Source/Common/gdcmSmartPointer.h?view=log