C++: Circular dependencies with headers. Using #ifndef and #define
I have the very simple following code:

main.cpp

    #include "ui_library_browser.h"
    #include <QtGui/QApplication>
    #include "StartWindow.h"
    int main(int argc, char *argv[])
    {
      QApplication a(argc, argv);
      StartWindow w;
      w.show();
      return a.exec();
    }

StartWindow.h

    #ifndef STARTWINDOW_H_
    #define STARTWINDOW_H_
    
    #include <qwidget>
    #include "MainWindow.h"
    
    class StartWindow : public QWidget
    { 
      Q_OBJECT
    
    public:
      StartWindow();
      ~StartWindow();
      MainWindow main_window;  //<-- Problem
    };
    #endif

MainWindow.h

    #ifndef MAINWINDOW_H_
    #define MAINWINDOW_H_
    
    #include <qdialog.h>
    #include "StartWindow.h"
    
    class MainWindow : public QDialog
    {
      Q_OBJECT
    
    public:
      MainWindow();
      ~MainWindow();
    };
    #endif

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?

Thanks in advance!
C++: Circular dependencies with headers. Using #ifndef and #define
===

I have the very simple following code:

main.cpp

    #include "ui_library_browser.h"
    #include <QtGui/QApplication>
    #include "StartWindow.h"
    int main(int argc, char *argv[])
    {
      QApplication a(argc, argv);
      StartWindow w;
      w.show();
      return a.exec();
    }

StartWindow.h

    #ifndef STARTWINDOW_H_
    #define STARTWINDOW_H_
    
    #include <qwidget>
    #include "MainWindow.h"
    
    class StartWindow : public QWidget
    { 
      Q_OBJECT
    
    public:
      StartWindow();
      ~StartWindow();
      MainWindow main_window;  //<-- Problem
    };
    #endif

MainWindow.h

    #ifndef MAINWINDOW_H_
    #define MAINWINDOW_H_
    
    #include <qdialog.h>
    #include "StartWindow.h"
    
    class MainWindow : public QDialog
    {
      Q_OBJECT
    
    public:
      MainWindow();
      ~MainWindow();
    };
    #endif

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?

Thanks in advance!