title: Find the list of member variables of a class and their types?
body: <p>I haven't ever heard it's possible, but asking with the hope that it might.<br>
  For a class with many more member variables than this:</p>
  
  <pre><code>class A
  {
   public:
    SomeOtherClass* s;
    int i;
    int j;
    A() {}
    A(const A&amp; soc): s(soc.s-&gt;Clone()), i(soc.i), j(soc.j) {}
  };
  </code></pre>
  
  <p>I always have to remember that if I add another variable <code>int k</code> to the class, I'll also have to add it in the initialization list <code>k(soc.k)</code> and sometimes in the destructor too.
  I've had to add/remove member variables so many times and it's really annoying to forget about the copying in the initialization list and finding the omission much much later while debugging.  </p>
  
  <p>Therefore, I wanted to know if there's a syntax/logic through which I can find out the list of member variables of a class and their types, so that I can maybe iterate through them and decide which of them need to be copied in the copy ctor and which of them need to be deep copied?  </p>
  
  <p>I don't see why the creators of C++ couldn't have included such a facility, since except for virtual members, the memory locations of variables would be contiguous and their types are known too. Even if they were extern or virtual, the type and size would be known at runtime. So shouldn't it be possible?</p>