Hi all, One more doubt regarding pointers and reference.Somewhere I saw a code like this Code: template<class T> class Abc { public: Abc(T* aPtr){iPtr=aPtr; } ~Abc(){delete iPtr; } T*& Ptr() const{return (T*&)iPtr; } T& operator ()(){return *iPtr; } void operator=(void* aNull) { delete iPtr; iPtr = (T*)aNull; } private: T* iPtr; }; Like this the class is defined. Here T*& is nothing but T.i.e here Ptr() is returning T.Instead of T why they have taken T*&. I have another doubt also.Is the code correct?I mean deleting iPtr in overloaded = operator. Thanks in advance. Regards, sharmila.
Probably the code is never going to run successfully. They have written the code with the frame in mind that they want to be deleting the memory without even thinking of allocating the memory.