1 2 3 4 5 6 7
void bar(A& a);
In the above example A has a data member of type B so it necessary to include B.h. The only use of A in B is a reference so we don't have to include A.h. Including A.h from B.h wouldn't even work because they include each other. We still need to tell the compiler that A is a class so for that reason we put a forward declaration of A (line 1) in B.h. In B.cpp you will probably have to include A.h, otherwise you will not be able to access the A object (call member functions, etc.) from the A reference.