devxlogo

Tip Bank

How to Access the Topmost Element of a Stack

You can access the topmost element (the one pushed the latest) of a stack container by using the member function top(): #include #include #include using namespace std;void main() { stack

Type-o-matic Text Box

This code creates a smart input box. Every time you type something into this text box, the first letters of your string are compared against the members of a hidden

Two Flavors of dynamic_cast<>

The operator dynamic_cast comes in two flavors: one uses pointers and the other uses references. Accordingly, dynamic_cast returns a pointer or a reference of the desired type when it succeeds.

Viewing bool Variables as Literals

By default, iostream objects display bool variables as 0 and 1. You can override the default setting by inserting the formatting flag boolalpha to the object stream. Consequently, the symbolic

MessageBox Advantage

You’ve probably noticed that the display time stops when an application pops up VB’s built-in MsgBox. Although the system timer continues to tick, the timer control isn’t updated every second,

Enum API Constants Save Time Coding

You can simplify Win32 APIs by using enumerated types instead of constants. When you use enumerated types, VB provides you with a list of values when you define the API

Risks of Using Reflection

Reflection plays an essential role in adding dynamism to Java. Using reflection, an application can dynamically (i.e., at run time) determine the state and behavior of any class. Reflection allows

Capturing a type_info Object

The operator typeid returns a const type_info object associated with its argument. However, the returned object is a temporary one, so if you have to call several member functions from