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++
Default functions implemented by compiler
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="Rolf Magnus, post: 2565785"] You are right that this definition is not correct. A deep copy is a copy where the whole content of the object is copied, while a shallow copy doesn't copy the data itself, but e.g. just its address, so that the original object and the copy share their data. The compiler-generated copy constructor does a deep copy. If you write your own, you can do anything you want. The default constructor has nothing to do with it. Well, if you have several objects that have a pointer to the same data, you have to ensure that it's not deleted multiple times or used after being deleted. However, failure to handle it correctly most often leads to undefined behavior. An exception might be thrown, but typically isn't. Actually, it's just the shallow copy that has that problem, because it usually means that after the copy operation, two objects have a pointer to the same data. A deep copy is unproblematic in that respect, but might be costly for large amounts of data. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default functions implemented by compiler
Top