Why static method overrides base class non-static method?

Viewed 3456
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:

  1. static method doesn't override the virtual functions in base class
  2. 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 ?)

2 Answers
Related