jeudi 2 mars 2023

A question about subclasses inheriting constant member functions

Click to view the code

I encountered such a problem. I created two classes, Base as the parent class, and Derived as the subclass. As shown in the figure, the "运行结果" in the figure means the result of the operation. I don't understand why the subclass missed const. Cause the rewriting to be unsuccessful, or why the subclass does not call its own defined f1 function. Sincere thanks to everyone who helped me

Aucun commentaire:

Enregistrer un commentaire