title: C++, Resetting class members without per-member-assignment
body: <p>In plain C it's common to reset a struct after instantiation:</p>
  
  <pre><code>struct MyClass obj;
  memset( &amp;obj, 0, sizeof(struct MyClass) );
  </code></pre>
  
  <p>This is convenient - especially when using an object oriented paradigm, since all members are guaranteed to be reset to null etc. no matter how many members are added over time.</p>
  
  <p>I'm looking for a way to do the same in C++. Obviously you can't simply reset the memory since the vtable is part of it. Also, in my particular case I can't use templates.</p>
  
  <p>One solution I've seen is to declare a struct with <em>all</em> members, which you in turn can reset in a single blow:</p>
  
  <pre><code>class MyClass{
  
    MyClass(){ memset(&amp;m, 0, sizeof(m)); }
  
    struct{
       int member;
    } m;
  };
  </code></pre>
  
  <p>I'm however not very fond of this solution.</p>
  
  <p>I guess "hacks" are available, and if you know one, please also say something about the risks of using it, e.g. if it can differ between compilers etc.</p>
  
  <p>Thanks</p>