Consider the following example:
class A {
public:
int foo() { return 1; }
int bar() { return foo(); }
};
class B : public A {
int foo() { return 2; }
};
int main() {
auto b = B();
return b.bar();
}
Why does main() return 1 insted of 2? Is foo() not the most visible function for B? Does there exist some override-feature for non-virtual classes to completely replace a function in every call? I know of CRTP, but it is quite verbose in this simple case.