1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
bf(C++) offers two ways to i(retrieve the type of objects) and expressions
while the program is running. The possibilities of bf(C++)'s
emi(run-time type identification) are limited compared to
languages like hi(Java) bf(Java). Normally, bf(C++) uses
i(static type checking) and i(static type identification). Static type
checking and determination is possibly safer and certainly more efficient than
run-time type identification, and should therefore be used wherever
possible. Nonetheles, bf(C++) offers run-time type identification by providing
the emi(dynamic cast) and ti(typeid) operators.
itemization(
it() The ti(dynamic_cast<>()) operator can be used to convert a base
class hi(base class: converting to derived class) pointer or reference to a
derived class pointer or reference. This is called emi(down-casting).
it() The ti(typeid) operator returns the actual type of an expression.
hi(expression: actual type)
)
These operators operate on class type objects, containing at least one
i(virtual member function).
|