What difference between forward declare and including headers?

Hi , I want to know what is the difference between including a header or forward declaring them?

class UParticleSystemComponent;
vs
#include "Componenets/ParticleSystemComponent.h"

Perhaps I want to use class UParticleSystemComponent;
For this Its important to Include its library header or forward Declare to access it.
What is good to use and why?

This is more of a C++ question than Unreal, I’m sure you’ll find some info if you look about online (e.g. stack overflow, or c++ blogs).

1 Like

As a rule of thumb, you want to include as few as possible classes to .h. Everything that can be forward declared and included in .cpp, should.

1 Like

Thanks for reply Sir , very informative and to the point :slight_smile:

Thanks for reply Sir , yes this is more C++ but I asked it here because I am learning C++ by developing games and this is the best forum with experienced and pro developers to discuss things with.