In my C++ project when do I have to use inclusion (#include "myclass.h") of header files? And when do I have to use forward declaration of the class (class CMyClass;)?
In my C++ project when do I have to use inclusion ( #include myclass.h
Share
As a rule try the forward declaration first. This will reduce compile times etc. If that doesn’t compile go for the
#include. You have to go for the #include if you need to do any of the following:new/delete, copy etc.(6,7,8,9 from @Mooing Duck)
They’re are probably more but I haven’t got my language law hat on today.