Introspection of classes

Introspection of classes

In Java using the java.lang.reflect classes, one can find out the name, class, and methods of an object simply by having a reference to that object. Is there a similar way of doing this anonymous introspection of classes using C++, or is the only way to have subclasses implement an interface that includes a way to get back this information?

C++ does not provide a standard mechanism of reflection and introspection. The overhead of implementing these features would be unacceptable both in terms of memory usage and execution speed. You can use RTTI to get some of that information (e.g., the class name) but not the names of its member functions or data members. If you need additional information, you need to implement interfaces that retrieve that information.


Share the Post: