I want to print all declared variables along with their types in my program.
#include<iostream>
int main(){
int a;
char b;
float c;
}
My program should out put
The Variables in the program: 'int a', 'char b' & 'float c'
I want to print all declared variables along with their types in my program.
#include<iostream>
int main(){
int a;
char b;
float c;
}
My program should out put
The Variables in the program: 'int a', 'char b' & 'float c'
You can't do this automatically in C++ since the C++ standard allows for all variable names to be compiled out in the final binary.
In this sense C++ is not a reflective language, unlike Java.
There are some tricks, but they rely on macros &c. See How can I add reflection to a C++ application?