Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Oct 25, 1999

Introspection of classes

Question:
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?

Answer:
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.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date