Does it make any sense to define “pure” virtual functions in the base class itself?

后端 未结 4 869
悲&欢浪女
悲&欢浪女 2021-02-07 15:38

The benefit of defining common virtual functions in the base class is that we don\'t have to redefine them in the derived classes then.

Even if we def

4条回答
  •  余生分开走
    2021-02-07 16:15

    are there any situations when it is beneficial to define a pure virtual function in the base class itself?

    Yes - if the function in question is the pure virtual destructor, it must also be defined by the base class.

提交回复
热议问题