c++ - Is virtual final method better than non-virtual one in a root class? -



c++ - Is virtual final method better than non-virtual one in a root class? -

i have abstract class root of hierarchy of classes. root class have method trivial implementation , seems there no need alter implementation anywhere anytime.

making method non-virtual fine, there chance subclass reimplement accident. virtual final method improve solution in case?

if decide declare method virtual... final, create users pay runtime cost of virtual dispatch in order protect little number of users might accidentally hide base of operations class' function.

since 1 of guiding principles in c++ "you don't pay for you don't use," improve leave function non-virtual, , allow derivers responsible if hide function.

c++ c++11

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -