suppose I have a class
class CAT
{
private:
int a;
long b;
double c;
string d;
};
now I need a function which can initialize all the members to a specific value, for example:
- int set to 0
- long set to -1
- double set to -1.1
- string set to unknown
so far, I can write a function named initMembers:
void initMembers()
{
a = 0;
b = -1;
c = -1.1;
d = "unknown";
}
but if I have 1000 classes like CAT, and some of them have 4 members, some of them have 40 members,..... so I have to write an initMember functuions for every class.
I wonder if there is way can traversed all the members inside a class?
Thanks advance for your help!
I mean I want initialize specific type with a corresponding value
for all members inside all classes
* int set to 0
* long set to -1
* double set to -1.1
* string set to unknown