mardi 18 décembre 2018

Why pure virtual function has to be void, in C++?

I read this from ABSOLUTE C++ fifth edition by WALTER SAVITCH. It says, every pure virtual function need to be a void function. But I have a pure virtual function that can not be implemented in base class, and I will need a return type for that function. For example;

 virtual double area()const=0; 

in base class area calculation is meaningless, but each specific geometric shape has its own formula to calculate area like,circle or square. What should I do?

Aucun commentaire:

Enregistrer un commentaire