I've read up a bit and apparently using pointers should be solving my issues but the terminology is starting to fry my brain.
I'm storing derived class objects in a map of the base class (using shared ptrs which appears to be what's worked best so far).
std::unordered_map<EUID, std::shared_ptr<Body>> entity_map;```
This map is stored inside an entity-manager object which instances a new entity as follows:
```cpp
entity_map.insert({ uid, std::make_unique<Body>(uid, pos) });```
Now my issue is I want to pass in an ID number & return a pointer to the corresponding object but this solution is only able to provide Body*, not pointers for the derived classes which would allow access to methods not defined in the base class. Is there a way to access the full derived object?
Pointer return function:
```Body* GetEntityPtr(EUID uid) {
return entity_map[uid].get();
}```
The following code has error E0144 since the return type does not match:
```DynamicBody* test_body2 = entity_manager.GetEntityPtr(2);```