Is there any reason not to make a member function virtual?

后端 未结 7 1230
既然无缘
既然无缘 2020-12-14 07:55

Is there any real reason not to make a member function virtual in C++? Of course, there\'s always the performance argument, but that doesn\'t seem to stick

相关标签:
7条回答
  • 2020-12-14 08:47

    The Non-Virtual Interface idiom makes use of non-virtual methods. For more information please refer to Herb Sutter "Virtuality" article.

    http://www.gotw.ca/publications/mill18.htm

    And comments on the NVI idiom:

    http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.3 http://accu.org/index.php/journals/269 [See sub-section]

    0 讨论(0)
提交回复
热议问题