Difference between (T&*) and T where T is a template

sharmila's Avatar, Join Date: Mar 2006
Contributor
Hi all,
One more doubt regarding pointers and reference.Somewhere I saw a code like this
Code: CPP
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.

Last edited by shabbir; 3May2006 at 18:16.. Reason: Better code formating.
coderzone's Avatar, Join Date: Jul 2004
Team Leader
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.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by coderzone
they want to be deleting the memory without even thinking of allocating the memory.