c++ : code explanation for method prototype with const = 0

This is a pure virtual method (=0) which is not supposed to change the data of the class (const). You should provide an implementation in one of the classes deriving from Weapon! See this: Difference between a virtual function and a pure virtual function

You are expected to derive from the Weapon (can be considered interface) concrete classes, such as Axe , Shotgun, etc … where you will provide the attack() method.

Leave a Comment