Better Alternatives to Macros
Macros in C++ are better avoided. They are unsafe, hard to debug, and may bloat your .exe files. C++ offers significantly better alternatives to them: 1. Function-like macros should be
Macros in C++ are better avoided. They are unsafe, hard to debug, and may bloat your .exe files. C++ offers significantly better alternatives to them: 1. Function-like macros should be
A non-explicit constructor taking a single argument is also a conversion operator, which casts its argument to an object of the constructor’s class. When the compiler has to resolve an
When two or more classes serve as base classes in multiple inheritance, you want to choose a distinct name for each member function in order to avoid name ambiguity: class
Void * can serve as a generic data pointer, yet it suffers from the well-known ailments associated with pointers: it can be NULL or a dangling pointer. Furthermore, it usually
Like ordinary functions, templates can have default type arguments. A good example is STL’s vector. It actually has two arguments–the second one is an allocator class template. Since an allocator
To allow the user to control long operations, use a single CommandButton to control starting and stopping a looping process: Dim Running As BooleanPrivate Sub CmdStartStop_Click() If Running Then ‘
It’s fairly common practice to add buttons to your date and numeric fields to allow users to select and display a popup calendar or calculator. However, to display a calculator
The algorithm shown in the tip, “Swap Values Using Only Two Variables” [“101 Tech Tips for VB Developers, Supplement to the February 1997 issue of VBPJ, page 25], crashes not
Arrays take less memory and are faster than collections. If you don’t need to use a collection’s keyed lookup, easy extensibility, and other features, use an array instead.