STL Stack: read access violation : <p>I have created a stack then using memcpy I copy the stack to a buffer. and later I try to create the stack object back using the buffer. But I am getting read access violation.</p>

<p>please see below the code that might explain the situation better.</p>

<pre><code>Byte *targetdata;
class DATA
{
    std::stack&lt;int&gt; scatter;
}data;
...
...
memcpy(targetdata, &amp;data, sizeof(DATA));
...
...
{
  DATA data2;
  memcpy(&amp;data2, targetdata, sizeof(DATA));
}// Get a read access violation here.
</code></pre>
