Miguel Mano Fernandes Miguel Mano Fernandes - 1 month ago 6
C++ Question

Do derived classes need their own version of a virtual function declared on base?

For instance, the class

Plant
has a
virtual void info()
method. The class
flower
derives from
Plant
.

Is
Plant
obligated to have its own implementation of the method?

Answer

If the function is pure virtual, that is declared virtual void info() = 0;, then No. Otherwise Yes.

Comments