October 27, 1999

Use Pointers to Parents

When trying to navigate through a complex class hierarchy from any given instance of an object, it’s useful to be able to reference its parent. But how do you clean

The Importance of Virtual Destructors

Some classes in the Standard Library do not have a virtual destructor or virtual member functions by design. These classes include std::string, std::complex, and all STL containers. The lack of

Toggle Toolbar Captions Using Tag

Many applications have an option to show the toolbars as text and image or text-only. I have seen programmers handle this with two toolbars and show them based on the

Beware of Object Slicing

Passing a derived object by value to a function that takes a base object by value may cause a problem known as “object slicing”; every additional data member declared in

Count Substrings

This little routine demonstrates how easily you can determine the number of substrings within a string, given any specified separator character(s). Pass the string to be parsed, and the separator,

Killing an Object Prematurely

Sometimes, you need to force an object to destroy itself because its destructor performs an operation needed immediately. For example, when you want to release a mutex or close a

Construct Shortcut to an Interface

hen using a class that implements an interface, it can be frustrating to have to create two variables to reference all the properties of both the interface class and the