Circle becomes abstract as soon as you change it's function field() to const, because field() const
is actually a totally different method than field()
, which is why field()
then remains undefined in Circle
so it is abstract.
I would suggest you use the new C++11-ish keyword override
in Circle::field()
to communicate to the compiler that you actually intend to override a virtual method. The compiler then refuses to compile if the field
function in your inherited type is not present and/or compatible in/with any virtual method in the base class.