Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should methods that implement pure virtual methods of an interface class be declared virtual as well?

I read different opinions about this question. Let's say I have an interface class with a bunch of pure virtual methods. I implement those methods in a class that implements the interface and I do not expect to derive from the implementation.

Is there a need for declaring the methods in the implementation as virtual as well? If yes, why?

like image 861
tyrondis Avatar asked Oct 26 '10 14:10

tyrondis


1 Answers

No - every function method declared virtual in the base class will be virtual in all derived classes.

But good coding practices are telling to declare those methods virtual.

like image 91
BЈовић Avatar answered Nov 13 '22 15:11

BЈовић