samedi 16 octobre 2021

Call functions from fellow child classes in C++

I have a parent class Piece that has several child classes including Queen, Rook and Bishop. However, a Queen can move like a Rook and a Bishop combined so it is conceptually the fusion of the two. I want to call functions from the Rook and Bishop class in the Queen class. I have tried making Queen inherit from both Rook and Bishop instead of inheriting from Piece however, then it inherits two copies of attributes from Piece (one in Bishop and one in Rook) which means I can't refer to either.

Is there a way to do this or do I just have to rewrite the functions for Queen?

Aucun commentaire:

Enregistrer un commentaire