This is neither overriding nor overloading. Since the parameter's type is different, MyDerived::doSome is just hiding MyBase::doSome.
1.1. Since DerivedContext derives from BaseContext, it might seems that I am overriding doSome.
No. Here're the preconditions of overriding listed in the standard. $10.3/2 Virtual functions [class.virtual]:
(emphasis mine)
If a virtual member function vf is declared in a class Base and in a class Derived, derived directly or indirectly from Base, a member function vf with the same name, parameter-type-list ([dcl.fct]), cv-qualification, and ref-qualifier (or absence of same) as Base::vf is declared, then Derived::vf is also virtual (whether or not it is so declared) and it overrides110 Base::vf.
110) A function with the same name but a different parameter list (Clause [over]) as a virtual function is not necessarily virtual and does not override.
In fact with override specifier you'll get a compile error for this case. e.g.
error: 'doSome' marked 'override' but does not override any member functions
1.2. But it might also be an overloading...
You can't overload functions across scopes according to the rule of unqualified name lookup (unless using using-declaration to introduce names into the same scope).
- Thus, if I type
(MyBase* my = new MyDerived())->doSome(new DerivedContext()), what should I get?
MyBase::doSome() will be invoked since you call it on a MyBase*. This is not overriding, so no dynamic dispatching happens here.
LIVE
Note the argument DerivedContext* will be implicitly converted to BaseContext* and then passed to the function. BTW (MyBase* my = new MyDerived())->... is not valid syntax.
overridedoesn't change the type - which isn't allowed. Was one of them supposed to take aBaseContextargument?