Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Please, help me. It's destructor problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Leo jay, post: 2582242"] since there are pointers in the class Person, and you want to assign values from one Person to another, you should write both copy construction and copy assignment to prevent multiple pointers point to the same area. so, add following code(copy construction) to class Person, the program will be ok. Person(const Person& p) { name = new char[strlen(p.name)+1]; strcpy(name, p.name); birthday = p.birthday; } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Please, help me. It's destructor problem
Top