![]() |
Some of the classes in the WebSphere value type library contain methods that accept instances of a superclass. For such cases, the library use a C++ dynamic_cast to determine the type of the passed object; for example:
CORBA::Boolean equals(CORBA::ValueBase& arg0) { ... OBV_java::lang::Integer* argInteger = dynamic_cast<OBV_java::lang::Integer*>(& arg0) ; ... }
This functionality allows you to perform type inquiries just as you would in Java using the "instance of" operator.
Another possible approach is to use the "typeid()" operator of the type_info class; for example:
#include <typeinfo> #include <iostream> using namespace std; class Test1 { __ }; class Test2 : Test1 {_..}; void main(void) { Test2* ptr = new Test2(); cout << typeid(*ptr).name() << endl; //yields the string "class Test2" }
Depending on the compiler that is used, you must enable certain options in order for this functionality to work properly. For example, for MSVC++ the /GR option must be added to the compiler settings.
Related tasks... | |
Creating your own C++ valuetypes | |
Related concepts... | |
Parent: CORBA value type library for C++ | |
C++ valuetype library, data type mappings | |
C++ valuetype library, application programming interface | |
CORBA value type considerations | |
Related reference... | |
C++ valuetype library, methods implemented | |