How to override virtual function in good style? [C++]

后端 未结 3 578
萌比男神i
萌比男神i 2020-12-20 17:11

guys I know this question is very basic but I\'ve met in few publications (websites, books) different style of override virtual function. What I mean is: if I have base clas

3条回答
  •  萌比男神i
    2020-12-20 17:50

    It is not necessary to add the virtual keyword to a method you override in a subclass as this qualifier can not be removed by omitting it in subclass declarations.

    It is however good practise to repeat the virtual keyword as it documents which derived functions are virtual in the base class.

    This is also recommended by the 'High Integrity C++ Coding Standard Manual'.

    which is linked in the C++ FAQ.

提交回复
热议问题