| | |
Can someone enlighten me on Deep Copy Problem?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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++?
Views: 231 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory multidimensional newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






