June 16, 1999

Using NULL in a Query’s Where Clause

While comparing a field to NULL, a SQL query should use the IS operator in place of the “=” operator. The reason is that if the ANSI_NULLS option is On for a connection, expressions being compared to a NULL value will not return a true or false value but rather

The Order of Destructors’ Call

An object’s destructor invokes the destructors of its direct base classes and member objects. The invocation occurs in the reverse order of the construction of the subobjects. Note, however, that all destructors are called with their qualified name, ignoring any possible virtual overriding destructors in derived classes. For example: struct

Use Namespaces to Facilitate Software Version Control

Successful software projects do not end with the product’s rollout. In most projects, new versions that are based on their predecessors are periodically released. Moreover, previous versions have to be supported, patched, and adjusted to operate with new operating systems, locales, and hardware. Web browsers, commercial databases, word processors, and

Be Careful With Initializers in Constructors

You should use caution when automatically initializing class variables. In this example, C1 calls setVal() in its constructor, and C2, a subclass of C1, overrides the method to set a value of a C2 variable: public class C1{ public C1() { setVal(); } protected void setVal() { }}public class C2

The Exception Specification of an Implicitly-Declared Default Constructor

An implicitly-declared default constructor has an exception specification. The exception specification contains all the exceptions of every other special member functions (for example, the constructors of base class and embedded objects) that the constructor invokes directly. To demonstrate that, consider this class hierarchy: struct A { A(); //can throw any

Working With Collections

When working with collections, use an error handler to easily determine if a given key exists in the collection. If you try to access an item from a collection where the key doesn’t exist, you’ll get an error. Likewise, if you try to add an item that exists, you’ll also