struct B {
void foo () {}
};
struct D : B {
using B::foo;
static void foo () {}
};
int main ()
{
D obj;
obj.foo(); // calls D::foo() !?
}
Member method and static
member method are entirely different for 2 reasons:
static
method doesn't override the virtual functions in baseclass
- Function pointer signature for both the cases are different
When a method is called by an object, shouldn't the member method have higher preference logically ? (Just that C++ allows static
method to be called using object, would it be considered as an overridden method ?)