title: Forcefully access private member
body: <p>Say I am using an open source library of someone who does not know what they're doing well. (no encapsulation for important members) Really it's a coworker who's code I'm not allowed to modify, nor is he willing to modify it for me.</p>
  
  <p>How can I forcefully access a private member without doing something like rewriting a fake class or modifying the original class?</p>
  
  <p>I've tried things like <code>#define private public</code>, but the class file includes some standard namespace files and this will give a compilation error.</p>
  
  <p>I've tried memory manipulation, but this requires member identification which isn't going to work. (See the following)</p>
  
  <pre><code>#define PX_ACCESS_PRIVATE( pObject, _Member ) ( static_cast&lt; std::size_t &gt;( pObject ) + static_cast&lt; std::size_t &gt;( &amp;( ( decltype( pObject )( nullptr ) )-&gt;_Member ) ) )
  </code></pre>
  
  <p>Any ideas?</p>