I have a C++ structure that have a few values, for example
struct test_sub
{
int G;
float H;
int I;
};
struct test
{
std::string A;
std::string B;
std::string C;
std::string D;
std::string E;
std::string F;
test_sub new_struct;
};
More elements(int, string or even another struct) could be added or removed in future iterations of my project.
I have to create GUI elements(currently in terminal itself) where I have to show Label as structure element name and its value, for example:
A = A value
B = B value
C = C value
D = D value
E = E value
F = F value
G = 22
H = 5.25
I = 6
Currently I have used hardcoded values to print, as below:
test st_test;
.
.
.
std::cout<<"A = "<<st_test.A<<std::endl;
std::cout<<"B = "<<st_test.B<<std::endl;
std::cout<<"C = "<<st_test.C<<std::endl;
std::cout<<"D = "<<st_test.D<<std::endl;
std::cout<<"E = "<<st_test.E<<std::endl;
std::cout<<"F = "<<st_test.F<<std::endl;
std::cout<<"G = "<<st_test.new_struct.G<<std::endl;
std::cout<<"H = "<<st_test.new_struct.H<<std::endl;
std::cout<<"I = "<<st_test.new_struct.I<<std::endl;
Please provide suggestions to remove this hardcoded situation. Thanks in advance.