Consider a simple example:
struct FooParent {
virtual void bar() { }
};
struct Foo: FooParent {
void bar() { }
};
int main() {
Foo foo;
void (Foo::*foo_member)() = &FooParent::bar;
//(foo.*FooParent::foo_member)();
foo.FooParent::bar();
}
As you can see one can use scope resolution on the foo
object when calling bar member function while there is no way to explicitly declare the scope for member function pointer. I accept that the syntax should be prohibited when using ->*
as the operator can be overloaded in sometimes unexpected way, but I cannot understand the reason behind preventing explicit scope resolution when dereferencing with .*
.
I am trying to disable virtual dispatch for a member pointer that points to a base class's virtual function.