I’m making a chess game and I would like to have an array of pieces.
If I’m correct, in Java you can have an abstract Piece class and have King or Queen extend that class. If I were to make an array of Pieces I could place a King piece somewhere in that array and a Queen piece at another spot because both King and Queen extend Piece.
Is there any way to do that with structures in C++?
Yes. You can create an abstract base class in C++. Simply set one or more of the methods to be pure virtual:
You can then create sub-classes that implement the pure virtual methods