title: Circular Dependancy Issue
body: <p>I've been writing an NES emulator this summer and I've ran into a roadblock.  I'm trying to test my ppu code, but I can't get my code to compile because of a circular dependency.</p>
  
  <p>What I currently have:</p>
  
  <ul>
  <li>Three classes: cpu, ppu and memory </li>
  <li>headers: cpu.h, ppu.h and memory.h</li>
  <li>cpp files: cpu.cpp, ppu.cpp, memory.cpp and main.cpp</li>
  </ul>
  
  <p>The dependency issue is in memory.h.  Currently, ppu.h includes memory.h so that I can access VRAM, and memory.h includes ppu.h so that I can update flags or addresses in VRAM depending on what the cpu writes to memory.  I've tried a forward declaration of the ppu class since I only use a ppu pointer, but this failed.  </p>
  
  <p>Here is what happens with an example piece of my code with a forward declaration:</p>
  
  <pre><code>case 0x2000:
  ppu-&gt;ppuTempAddress |= ((data &amp; 0x03) &lt;&lt; 10);
  break;
  </code></pre>
  
  <p>And the error:</p>
  
  <pre><code>In file included from memory.cpp:1:0:
  memory.h:7:7: error: forward declaration of ‘class ppu’
  memory.cpp:99:10: error: invalid use of incomplete type ‘class ppu’
  </code></pre>
  
  <p>include "ppu.h" outputs this error (which doesn't occur without the include):</p>
  
  <pre><code>In file included from memory.h:6:0,
                   from memory.cpp:1:
  ppu.h:13:20: error: ‘memory’ has not been declared
  ppu.h:63:25: error: ‘memory’ has not been declared
  ppu.h:66:29: error: ‘memory’ has not been declared
  </code></pre>
  
  <p>Any suggestions on what to do from here?  I'm stumped.</p>