overriding with difference access specification c++

后端 未结 4 1836

I came across a question while taking iKM test. There was a base class with two abstract methods with private access specifier. There was a derived class which was overridin

4条回答
  •  遥遥无期
    2020-12-11 18:17

    Yes, this is allowed as long as the signature is the same. And in my opinion, yes, you're right, overriding visibility (for example, public -> private) breaks IS-A. I believe Scott Myers Effective C++ series has a discussion on this one.

提交回复
热议问题