I'm having a bit of trouble overriding a function from a base class.
Here's my GameObject class:
namespace GameEngine {
    class GameObject {
    public:
        virtual void render() {
            std::cout << "Render Game Object" << std::endl;
        }
    };
}
And here's my Player class:
class Player : public GameEngine::GameObject {
public:
    void render() {
        std::cout << "Render Player" << std::endl;
    }
};
In MainComponent.cpp I have a Vector of GameObjects, and I loop through them to render them
Player player;
vector<GameEngine::GameObject> gameObjects;
void MainComponent::init() {
    gameObjects.push_back(player);
    gameLoop();
}
void MainComponent::render() {
    for(int i = 0; i < gameObjects.size(); i++) {
        gameObjects[i].render();
    }
}
I would expect this code to output "Render Player", since the only object in the gameObjects vector is a Player, but instead it outputs "Render Game Object". Is there a way that I can force the Player object in the gameObjects vector to use the Player render as opposed to the GameObject render?
 
     
     
     
     
    