I am trying to understand a point here in C++.
If class A has a non-virtual method, and class B, which extends A, overrides that method, can i create an instance of B and somehow use the method defined in B?
Is there a point to override a non-virtual method?
I am trying to understand a point here in C++. If class A has
Share
You are not actually overriding, but this is the behavior, i.e
So, the pointer/reference type determines the method called.
Yes. The pointer/reference type has to be of type B. (see previous example).
If you don’t declare
methodto bevirtual, you cannot override it, but you can hide it.