This is my entity manager class, it has a vector, and a pointer to that vector
class EntityManager {
private:
public:
std::vector<MapEntity> vAllMapEntities;
std::vector<MapEntity>* pvAllMapEntities = &vAllMapEntities;
EntityManager();
int CountObjectsInMapEntityList();
};```
This is my Map Entity class.
```cpp
MapEntity::MapEntity() :
mposx(0.0), mposy(0.0), entitybox{200, 100, 50, -50} , render_pointer(&all_trees), pEntManagerMeidList(EntityManager::vAllMapEntities){
SendToRender();
}```
My aim:
to get each newly created mapentity object to call in its constructor a function to add a variable of itself into the vector of entity manager.
The one thing I am stuck at is in the map entity:
In the constructor of map entity i cant get the syntax right to reference the entity manager vAllMap Entities vector (or the pointer to it), the error message is:
`A non static member reference must be relative to a specific object`
I made sure that the entity manager is called before any mapobject is created.
Is it even possible to do what I want to do? To repeat the question: I want to get hold of the vector in another class from the constructor of this class or or the pointer (of that other class) pointing to a member of itself (or alternatively have a pointer from this class to the other classes vector. However then I wonder why do coding books say "public members are accessible everywhere".