I have a question about c++ header files and their includes.
Consider the following scenario.
I have a following files and code inside :
A.h
class A
{
// ...
};
A.cpp
#include "A.h"
// implementation of A
B.h
class B
{
A object;
}
B.cpp
#include "A.h"
#include "B.h"
/// implementation of B
When I try to build, the compiler gives an error in B.h, that can't recognize A, because I didn't include A.h.
The question is why compiler compiles header files separately, if they are included in some cpp files and include preprocessor is doing the copy / paste full content of header file and header file content will be compiled with cpp file, where it included.