I have a question about when to use forward declaration vs. include header. I know that there are a lot of questions similar to this out there, but there's just one thing that's a bit confusing.
I've seen the following way in a source code I was looking at:
classA.h
#ifndef H_CLASSA
#define H_CLASSA
class classB;
class classA {
public:
classA(B* b);
};
and then in classA.cpp:
#include "classA.h"
#include "classB.h" // dependency
classA::classA(B* b) { b->someMethod(); }
In cases like this I've just put #include "class.b" in the classA-header from the start since A has a dependency on class B and uses it. But I don't get why you would forward declare classB first in the header and then include the classB.h in the source file?
Thanks in advance!