0

I am working on someone else project in C++. There are many variables which are created based on other classes. For example:

Class_C newVariable;

which Class_C is created based on Class_B and may be inherit from Class_A and so on, thus newVariable may contain many class members.

Is there anyway or easy to print or display all members of newVariable in C++?

ps. I am using Visual Studio for coding and debugging.

Richard Dally
  • 1,432
  • 2
  • 21
  • 38
s_m
  • 129
  • 8
  • No, that would require reflection. The most you can currently get is the class name. Something like intellisense in Visual Studio is what would help you the most. – VoidStar Sep 25 '15 at 03:14

1 Answers1

3

I recently asked myself the same question. Take a look at the following discussions:

how-can-i-add-reflection-to-a-c-application

generic-way-to-print-out-variable-name-in-c

Meta Classes

"Reflection" Visual Studio

To sum it up, C++ is built for speed, there is no way to get the info about your classes (during the runtime), at least not using a core feature of C++ (as we have reflection in Java). There are different tricks and extensions to do that (as you can find in the links posted above), but they are still... tricks and extensions.

Community
  • 1
  • 1
asalic
  • 664
  • 3
  • 6