Tip Bank

DevX - Software Development Resource

Check for Available Memory Programmatically

If an application’s behavior is dependent on the amount of available memory, then this code fragment can be used to determine what action an application should take. For example, a

DevX - Software Development Resource

Use enum Types in switch Statements

Certain compiler and code analyzers can detect a missing enumerator in a switch statement. Consider: enum Seasons{ Winter, Spring, Summer, Fall};switch (s){case Winter: wearCoat(); break;case Spring: pruneGarden(); break;case Summer: goSwimming();

DevX - Software Development Resource

Concatenating Variables

If you need to concatenate variables of different types to form a string, use a stringstream object. The header contains the declarations of the stringstream family of classes. Using its

DevX - Software Development Resource

Reading a String from the Standard Input

There are two methods of reading a string from the standard input. The first one uses getline(), as in the following example: std::string name;getline(cin, name); // option #1 The second