2 added 62 characters in body
source | link

Initialize your player/enemy as your base type.

GameObject* obj = new Player();

You can now store it in your list. You need to cast it to a player object to be able to use the players methods/members. Look up the visitor pattern, very useful with this type of architecture.

Edit: do note that it's now a pointer and is heap allocated.

Initialize your player/enemy as your base type.

GameObject* obj = new Player();

You can now store it in your list. You need to cast it to a player object to be able to use the players methods/members. Look up the visitor pattern, very useful with this type of architecture.

Initialize your player/enemy as your base type.

GameObject* obj = new Player();

You can now store it in your list. You need to cast it to a player object to be able to use the players methods/members. Look up the visitor pattern, very useful with this type of architecture.

Edit: do note that it's now a pointer and is heap allocated.

1
source | link

Initialize your player/enemy as your base type.

GameObject* obj = new Player();

You can now store it in your list. You need to cast it to a player object to be able to use the players methods/members. Look up the visitor pattern, very useful with this type of architecture.