alright so basically what i have is 2 structs that have varying number of members in them and i need to iterate through and send to a method. the only problem is is that this is not my code and i can only add to it not change existing things. i was wondering if there is a way to do this in 1 method instead of 1 method for every possibility.
example time
struct a
{
string val1;
double val2;
};
struct b
{
int val1;
int val2;
int val3;
}
template<typename T>
void func(T temp)
{
//do work with all the variables in the struct
//ie for(...blah...){cout<<blah<<endl};
}
i know there is no way to get the name of the variables in c++ but if there is a new way to do that i would also like to know how to do that.
Aucun commentaire:
Enregistrer un commentaire