February 3, 1998

Copy constructor and operator= go together

If you do not define a copy constructor and operator = , the compiler will create them automatically for you. However, there are cases when you have to define them explicitly. In such cases, remember to define both of them and not just one. Otherwise, your compiler will create the

Better alternative to #define constants

Using #define to create macro constants is not ideal. Macros are substituted by the preprocessor, so the compiler usually cannot detect anomalies such as type mismatch (see example); furthermore, most symbolic debuggers will not allow you to examine a macro

Explicit destructor invocation

One of the good things about destructors is that they are called automatically. There are rare cases, however, when you want to invoke an object

Avoid reduplicating identical pieces of contructors’ code

There are cases where you have to define several constructors (or constructors and operator = ) within one class, all of which perform some identical tasks (e.g., initialize members, allocate memory, and so on), plus additional individual functionality, as in the following example: class Personnel { int children; float salary;