title: How do you cast away const'ness when the function takes a reference to the object (and access non-const methods)?
body: <p>I have a back up copy of data that I would like to protect so I made it <code>const</code>. I need to violate that <code>const</code>ness on two occassions, once to store virgin data to it:</p>
  
  <pre><code>fgBlocks.CopyInto((BlkArray&amp;)backUpCopy);
  </code></pre>
  
  <p>w.r.t.</p>
  
  <pre><code>result CopyInto(BlkArray &amp;replica) const {/**/}
  </code></pre>
  
  <p>and again when I call <code>RemoveAll()</code> on it which is a non-const method:</p>
  
  <pre><code>((BlkArray)backUpCopy).RemoveAll(true);
  </code></pre>
  
  <p>Is the first cast (shown above, <code>(BlkArray&amp;)</code>) correct? It's the one aspect of indirection I haven't cast to before now. Then again I'll add another unused aspect, that of casting away <code>const</code>ness for calling an object's methods, which the compiler isn't accepting as shown above.</p>
  
  <p>The members are declared like this:</p>
  
  <pre><code>BlkArray fgBlocks;
  const BlkArray backUpCopy;
  </code></pre>
  
  <p>I'm trying to extend Correa's solution so have:</p>
  
  <pre><code>    BlkArray *pBUCopy = (BlkArray *)&amp;backUpCopy;
      fgBlocks.CopyInto(*pBUCopy);
  </code></pre>
  
  <p>Only problem now is the compiler is failing due to</p>
  
  <blockquote>
    <p>uninitialized member 'MyClass::backUpCopy' with 'const' type 'const BlockArray'</p>
  </blockquote>