main.cpp:
#include "a.h"
#include "b.h"
int main() {}
a.h:
#ifndef A_H
#define A_H
#include "b.h"
struct A {
bool someFlag;
A (B inB);
};
#endif
b.h:
#ifndef B_H
#define B_H
#include "a.h"
struct B {
bool someFlag;
void SomeFunct (A inA);
};
#endif
a.cpp:
#include "a.h"
A::A(B inB) {
flag=!inB.flag;
}
b.cpp:
#include "b.h"
void B::SomeFunct(A inA) {
flag=inA.flag;
}
Попытка скомпилить:
% g++ ./main.cpp
In file included from ./a.h:4,
from ./main.cpp:3:
./b.h:8: ошибка: ‘A’ has not been declared
Что не так с инклудами и хедерами?