Okay, I have a question about how I should return a polymorphic class from a function. I have a class hierarchy like this:
class Component
{
...
};
class Graphic : public Component
{
void linkTexture(Texture);
...
};
class Sound : public Component
{
...
};
//And so on with more components that each have their own thing to do
Alright, I have a container of Component* in a system class. I want to return a Component* from a getComponent function, to be able to access the component's methods outside of the system class. Will it work, and is it kosher to have one:
Component* System::getComponent(...);
That will return whichever component I ask for, and it will know whether it is a Graphic, a sound, a physics entity so I can access the distinct methods from each class?