I have the very simple following code:
main.cpp
#include \"ui_library_browser.h\"
#include
#include \"StartWindow.h\"
int
Do you use StartWindow in MainWindow? If not, simply remove the StartWindow.h include. Otherwise make the main_window a pointer instead of a variable.
So called "header guards" are used to prevent a bit different kind of error: including same header multiple time through different indirect inclusions in one compile unit. For example, you include "a.h" from main.cpp and then include "b.h" from main.cpp, that includes "a.h" itself somewhere inside.
In your case two headers try to include each other circurally, that is not possible - C/C++ preprocessor works as simple text "copy-paste" and this case would invent infinite recursion of text insertion.
And I really don't see why would you need "StartWindow.h" inclusion in "MainWindow.h" header.
In the file StartWindow.h remove #include "MainWindow.h"
and add the forward declaration (before class StartWindow ...
):
class MainWindow;
In the same file change the member MainWindow main_window
to
const MainWindow* main_window;
or
const MainWindow& main_window;
In the latter case you would need to pass const MainWindow&
in the constructor of StartWindow
.