| | |
Can someone enlighten me on Deep Copy Problem?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 25
Reputation:
Solved Threads: 0
I have an function in which I want to make a copy of an object.
For some reason that doesn't work. If I use the copy constructor like this
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?
C++ Syntax (Toggle Plain Text)
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
C++ Syntax (Toggle Plain Text)
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?
![]() |
Similar Threads
- simple linked list implementation problem (C++)
- Deep copy of a struct (C++)
- Problem when using a template classes to store user-defined types (C++)
- Member function copy() ??? (C++)
- I have problem with deep copy (C++)
- (C++) Writing a Copy Constructor?!? (C++)
- Playing with shared memory - problem with non 'simple' data types (C++)
Other Threads in the C++ Forum
- Previous Thread: C++, Visual C++ or Java for Win32API firewall application?
- Next Thread: Is .NET good option to make a GUI in C++?
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






