I have an function in which I want to make a copy of an object.
ClassBase
{
public:
Tblk myTblk;
private:
};
void ClassBase::CopyObject(const ClassBase &test)
{
TblkPtr_t myTblk = TblkPtr_t(new Tblk); //TblkPtr_t is a typedef shared pointer
*myTblk = *test.myTblk;
}
For some reason that doesn't work. If I use the copy constructor like this
myTblk = new Tblk(*test.myTblk)
then it seems to work. I don't understand why if I dereference the pointer in my original example why it wouldn't work. Can someone enlighten me?