devxlogo

Tip Bank

A Pure Virtual Destructor

Unlike ordinary member functions, a virtual destructor is not overridden when redefined in a derived class. Rather, it is extended: the lower-most destructor first invokes the destructor of its base

Exported Templates Can Reduce Compilation Time

A template definition can be #included in several translation units (source files). However, each time it is #included the definition is recompiled. Using large template definitions can increase compilation time

How to Disable Further Derivation of a Class

In some rare cases, it is useful to disallow further derivation of a class. Classes that implement system API or sensitive security management are good examples for that. Declaring the

Standard Exceptions

C++ defines a hierarchy of standard exceptions that are thrown at run time when abnormal conditions arise, such as when operator new fails. The standard exception classes are derived from

Two Distinct #include Directives

The preprocessor #include directive appears in two flavors: #include < vector > // angular brackets and #include “myclass.h” // quotes The two are not interchangeable. The angular-bracket version applies to

Create a Globally Unique Identifier (GUID)

I use this routine in almost every application I develop. It’s handy whether you need a key for a collection or whether you use it in a database: Option ExplicitPrivate

Use UNC Names to Refer to Network Drives

If you write programs that access information on a network server, you never want to hard-code drive letters. Not all software vendors take advantage of the Uniform Naming Convention (UNC)