Search 82,021 tutors
Newest Most Active

What is this Rule of Three? It's a common guideline for object design in C++ worth knowing to help you understand the trickiness of implicitly declared methods the compiler adds to your code that you may not be aware of. This can sometimes cause strange behavior in your objects that can be difficult to debug and cause less than desirable effects. What am I talking about? Well first let's have an introductory example. Say you have this simple class. class SimpleClass { int num; }; Now what you may not realize is that all class objects need certain methods when used and that if they aren't explicitly defined by the programmer it's the compiler's job to create them. The basic functionality an object needs is the ability to be constructed, destroyed, copied, and assigned. So after the compiler works its magic that simple class from above may have object code generated which is equivalent to as if you had written the following. class SimpleClass { int... read more

RSS Adam's Blog RSS feed