c++ Copy Constructor Conventions
A couple of very simple to follow rules for copy constructors.
Case A: An object has no dynamically allocated pointers. Let the default copy constructor do the work and don't bother writing one.
Case B: If said object does contain dynamic pointers, then you'll need to write your own copy constructor as follows.
Case A: An object has no dynamically allocated pointers. Let the default copy constructor do the work and don't bother writing one.
Case B: If said object does contain dynamic pointers, then you'll need to write your own copy constructor as follows.
MyObject(const MyObject& o) {
// Do some stuff for a true deep copy
// Make new pointers and stuff :)
}
1 Comments:
Howdy, I do think your website could possibly be having internet browser compatibility problems.
When I look at your website in Safari, it looks fine however when
opening in Internet Explorer, it's got some overlapping issues. I merely wanted to provide you with a quick heads up! Aside from that, wonderful blog!
Check out my web site; laser cellulite treatment
Post a Comment
<< Home