Hello All,
I am working on a project, a Tic-Tac-Toe game. I have written objects to represent 3 different players, a human player and two different computer AI players.
I want to be able, at run-time, to select which of these three player types are playing. Ideally I would want two pointers called player1 and player2 and then create 2 players from the three types (human and two AIs) and then point them to the player1 and player2 pointers. This would mean my game loop could switch between players using the pointers player1 and player2.
So my question is can c++ do this? Can I set up a generic pointer that I can assign to any object? I know it can be done with the basic data types (int, char etc.) but I can't figure out how to use a void pointer for objects.
Andy help would be much appreciated.
Thank you for your time
Andrew
I am working on a project, a Tic-Tac-Toe game. I have written objects to represent 3 different players, a human player and two different computer AI players.
I want to be able, at run-time, to select which of these three player types are playing. Ideally I would want two pointers called player1 and player2 and then create 2 players from the three types (human and two AIs) and then point them to the player1 and player2 pointers. This would mean my game loop could switch between players using the pointers player1 and player2.
So my question is can c++ do this? Can I set up a generic pointer that I can assign to any object? I know it can be done with the basic data types (int, char etc.) but I can't figure out how to use a void pointer for objects.
Andy help would be much appreciated.
Thank you for your time
Andrew