The reason why the problem happened was probably this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
// TableDlg.h
#ifndef TABLEDLG_H
#define TABLEDLG_H
#include "OverlayDlg.h"
class CTableDlg {
/* ... */
};
// OverlayDlg.h
#ifndef OVERLAYDLG_H
#define OVERLAYDLG_H
#include "TableDlg.h"
class COverlayDlg {
/* ... */
};
// TableDlg.cpp
#include "TableDlg.h"
/* ... */
// OverlayDlg.cpp
#include "OverlayDlg.h"
/* ... */
|
Now, the .cpp files are just empty but the includes (They are required for this to happen tho, despite that not being the reason).
Think about the compiling of tabledlg.cpp:
1. Include TableDlg.h
TABLEDLG_H gets defined
2. Include OverlayDlg (from TableDlg.h)
OVERLAYDLG_H gets defined
3. Re-include TableDlg.h
TABLEDLG_H is already defined, file is skipped.
4. Declare COverlayDlg
All right until now
5. Try to use CTableDlg in COverlayDlg
CTableDlg is not declared yet! This is the error.
To avoid this, pre-declare the classes before the class they're used into.
1 2 3 4 5 6 7 8 9 10 11
|
// OverlayDlg.h
class CTableDlg;
class COverlayDlg {
CTableDlg* pTable;
};
// TableDlg.h
class COverlayDlg;
class CTableDlg {
COverlayDlg* pOverlay;
};
|
Now, you already (hopefully) have the solution, but this is why it happened, in case you wondered.
Another way is to move includes before the header guards, but I can't guarantee it works.