You must enter any variables in the program and output them to the console or to the form. For example: we declared int a, string b, char p. It should appear: a, b, p. How to do it on c ++? in c # there is a function nameof () for this, but there is no such analogue in the pluses.
1 answer
Reflection in C ++ is not supported.
Counter question - if you enter a variable, then you know its name. Is it logical So you can just take it out with your hands, no? :)
Another option is via macros, such as
#define DEF(type, var) type var; string var##_name = #var; But, generally speaking, I do not see much sense of this action in the compiled, not interpreted language. After all, after assembling the program, there are still no names, only addresses :)
|
STR(var) #var << '=' << var- 0xdb