kooldart - 9 months ago 33
C++ Question

pointer variable of class 'Entity' within class 'Component', gives errors even though 'Entity.h' has been included

Okay So I'm making my own Entity Component System, and I'm trying to have an Entity pointer object within a Component class, but the object(variable) gives me a ton of errors, even though it has been included.

'Component.h'
#include "Entity.h"
class Component {

public:
Entity* ThisEntity;

}


That doesn't work, and gives me 76 errors inside 'Entity.h', all of which don't recognize my custom types(like Component, string, etc).
I usually use a global header file which has all the global variables, and includes everything necessary, like this:

'Public.h'

#ifndef Entity_h
#include "Entity.h" // Entity is include guarded
#endif


When i try to include 'Public.h' inside 'Component.cpp' it still gives me errors:

'Component.cpp'

#include "Public.h"
#include "Component.h" // The arrangement is correct, public before component but this still doesn't work


When I hover over the pointer variable "Entity* ThisEnt" it shows me "Entity Class", so it recognizes it but it still gives me 76 errors.