Tip Bank

DevX - Software Development Resource

Mutually exclusive list boxes

Many Windows programs use two adjacent list box controls to let the user select a number of items from a list of available values; such list boxes are mutually exclusive,

DevX - Software Development Resource

Using Enter to move to next field

Most MsDos programs used the Enter key to move from one field to the next one. You can easily simulate this behavior by setting the form’s KeyPreview property to True

DevX - Software Development Resource

SetFileSize – Trim or extend a file’s size

Option ExplicitPrivate Declare Function CreateFile Lib “kernel32” Alias “CreateFileA” (ByVal _ lpFileName As String, ByVal dwDesiredAccess As Long, _ ByVal dwShareMode As Long, lpSecurityAttributes As Any, _ ByVal dwCreationDisposition As

DevX - Software Development Resource

Avoid Unused Command Line Arguments

Many code wizards and automated source code generators synthesize the following main() template, even if the application doesn’t use command line arguments: int main(int argc, char* argv[]){ return 0;} This

DevX - Software Development Resource

Constructor Call Sequence

The constructors in a class hierarchy execute in the following sequence: base class constructors are called first, then member object’s constructors, and finally, the constructor of the derived class executes.

DevX - Software Development Resource

Disabling Further Derivation of a Class

Although the advantages of disabling further derivation of a class are often doubtable, C++ allows you to do that by declaring a class’s constructor and other special member functions private.

DevX - Software Development Resource

The auto Keyword

‘auto’ is undoubtedly the least used C++ keyword. This is because it’s always redundant. auto indicates local automatic storage type, for example: int main(){ auto int x; auto char s[10];}

DevX - Software Development Resource

Detecting the vptr’s Location

The precise location of the vptr (the pointer to the class’s table of virtual functions’ addresses) is implementation-dependent. Some compilers, e.g., Visual C++ and C++ Builder, place it offset 0,