C++ Style: Prefixing virtual keyword to overridden methods

后端 未结 6 623
名媛妹妹
名媛妹妹 2020-12-09 03:15

I\'ve been having a discussion with my coworkers as to whether to prefix overridden methods with the virtual keyword, or only at the originating base class.

I tend t

6条回答
  •  执念已碎
    2020-12-09 03:24

    I completely agree with your rationale. It's a good reminder that the method will have dynamic dispatch semantics when called. The "that method isn't virtual" argument that you co-worker is using is completely bogus. He's mixed up the concepts of virtual and pure-virtual.

提交回复
热议问题