I'm attempting to write a basic program that demonstrates the use of pure virtual functions in classes. For some reason though, after I've defined my virtual base class and my derived class with the overwriten pure virtual function, I cannot use my derived class without the following error coming up,
"Object of abstract type "derived class" is not allowed: Pure Virtual Function "Base Class::Virtual Function" has no overrider."
You did not actually override the pure virtual function calcArea() causing the derived class to be of abstract type also
Look @ this pure virtual function virtualvoid calcArea() const = 0; // Pure virtual function
and this : void calcArea(double); // doesn't match w/ the function above
I think calcArea() should be non-constant because you will modify the member area_
( or declare area_ as mutable )
Hey, I'm doing the same homework right now! xD You in Hardnett's class? I see you made area protected instead of private, even though it says to make it private in the book. I'm considering doing the same thing because I can't figure out how to make this work otherwise.
If you want to make the area private instead of protected you can simply use the public interface you already have for the Shape class, i.e. using GetArea().