I am struggling to understand inheritance. In the project I am working on I would to have a class called Game and then sub classes of Game that are my player ect. So when I load all my game objects into a vector in my render engine it calls the individual draw functions for each sub class. How would I do this exactly?
I would to have a class called Game and then sub classes of Game that are my player ect
That makes no sense at all to me. In what way is your player, in the game, a kind of game? That makes no sense and if you build something that makes no sense you're going to do yourself no favours at all. When you inherit, you're saying that the sub class IS a kind of base class. if you inherit player from game, you're saying the player IS a kind of game. The code doesn't care and if you mash it into compiling, it will happily compile, but you'll have created something really difficult to think about.
So when I load all my game objects into a vector in my render engine it calls the individual draw functions for each sub class. How would I do this exactly?
If you have a big vector of pointers-to-objects, you can iterate over the vector and call each object's draw function.
for (auto object_pointer : everything_that_needs_drawing)
is known as a range based for loop, since C++11. It's a much simpler and cleaner way of doing a for loop, iterating through every object in a container.