why do I need class forward declaration ?

I am checking some codes try to understand it. I saw some class forward declarations. E.g.:

In class A in A.cpp, I saw one line code as:
class B;

Class B is defined in B.cpp while it has B.h.

So my question is if in A.cpp, I do:
#include "B.h"
Then I don't need forward declarations like "class B" anymore, correct? If yes, then when should I use class forward declaration instead of #include header file?
If no, why?

Thanks a lot.
Anyone can help?
Use forward declarations to break include cycles. If b.h must include a.h, then a.h should not include b.h. You see this pattern when two classes have circular dependencies.
Topic archived. No new replies allowed.