title: It's right to use memcpy to copy a class object?
body: <pre><code>class SomeClass
  {
  public:
      int SomeFunc();
      virtual void DoSomeThing();
      void Copy(MyContainer* container)
      {
          //Is this line OK?
          //why not memcpy(container-&gt;data, this, sizeof(SomeClass) ?
          memcpy(&amp;container-&gt;data, this, sizeof(SomeClass));
      }
  
      SomeClass* GetFromCopy(MyContainer* container)
      {
          //And this ?
          return (KLunaBase*)&amp;container-&gt;pData;
      }
  
      void Test()
      {
          MyContainer* cont = NULL;
          container = malloc(sizeof(cont) - sizeof(cont-&gt;data) + size);
          Copy(cont);
      }
  
  private:
      int a;
      int b;
      SomeOtherClass objA;
  }
  
  struct MyContainer
  {
      const void* data;
  }
  </code></pre>
  
  <p>I have read some historic code, which simplified above, the function <code>Copy</code> and <code>GetFromCopy</code> I could not understand.
  I know that POD class can copy, but what if the class have virtual function and reference member object ? </p>
  
  <p>sorry for my poor English.</p>