Saturday, December 10, 2005

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.
MyObject(const MyObject& o) {
// Do some stuff for a true deep copy
// Make new pointers and stuff :)
}

1 Comments:

Anonymous Anonymous said...

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

6/04/2013 6:38 PM  

Post a Comment

<< Home