HP aC++/HP C A.06.25 Programmer's Guide
bool values behave as integral types and participate in integral promotions. Types
bool, char, wchar_t, and the signed and unsigned integer types are collectively
called integral types. A synonym for integral type is integer type. The representations
of integral types shall define values by use of a pure binary numeration system.
Example
void main(){
bool b=true; // Declare a variable of type bool and set it to true.
if (b) // Test value of bool variable.
b=false; // Set it to false.
}
dynamic_cast Keyword
The keyword dynamic_cast is used in expressions to check the safety of a type cast
at runtime. It is the simplest and most useful form of runtime type identification. You
can use it to cast safely within a class hierarchy based on the runtime type of objects
that are polymorphic types (classes including at least one virtual function). At runtime,
the expression being cast is checked to verify that it points to an instance of the type
being cast to.
Usage
A dynamic cast is most often used to cast from a base class pointer to a derived class
pointer in order to invoke a function appearing only in the derived class. Virtual
functions are preferred when their mechanism is sufficient. Usually a dynamic cast is
necessary because the base class is being specialized, but cannot (or should not) be
modified.
Example
class Base {
virtual void f(); // Make Base a polymorphic type.
// other class details omitted
};
class Derived : public Base {
// class details omitted
};
void Base::f()
{
// define Base function
}
void main()
{
Base *p;
Derived *q;
182 Standardizing Your Code