title: Circular dependencies with headers. Using #ifndef and #define
body: <p>I have the very simple following code:</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include "ui_library_browser.h"
  #include &lt;QtGui/QApplication&gt;
  #include "StartWindow.h"
  int main(int argc, char *argv[])
  {
    QApplication a(argc, argv);
    StartWindow w;
    w.show();
    return a.exec();
  }
  </code></pre>
  
  <p>StartWindow.h</p>
  
  <pre><code>#ifndef STARTWINDOW_H_
  #define STARTWINDOW_H_
  
  #include &lt;qwidget&gt;
  #include "MainWindow.h"
  
  class StartWindow : public QWidget
  { 
    Q_OBJECT
  
  public:
    StartWindow();
    ~StartWindow();
    MainWindow main_window;  //&lt;-- Problem
  };
  #endif
  </code></pre>
  
  <p>MainWindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H_
  #define MAINWINDOW_H_
  
  #include &lt;qdialog.h&gt;
  #include "StartWindow.h"
  
  class MainWindow : public QDialog
  {
    Q_OBJECT
  
  public:
    MainWindow();
    ~MainWindow();
  };
  #endif
  </code></pre>
  
  <p>This produces errors because of the inclusion of #include "StartWindow.h" in the MainWindow.h header.  However, I thought the use of #ifndef and #define are to stop problems like this?  Can someone clear this up for me?</p>