Possible Duplicate:
Iterate through struct variables.
So I have a header file and a code file. The class is representation of a View that will be queried from stored proc. For each col. in view there is one data member in class. Currently in code we have something like this:
Load( Reader reader)
{
   m_col1 = reader("m_col1");
   m_col2 = reader("m_col2");
   ..
}
How can I write a code that will iterate through member variables and give me code like:
Load( Reader reader)
{
   For (each str in ArrayOfMemberVariables)
     variableLValue(str) = reader(str); //  str = m_col1,  m_col2  ...
}
 
     
     
    