Weird C++ behaviour
class Base {
public:
void Method( int a, int b ){};
};
class Base {
public:
void Method( int a, int b ){};
};
class Derived : public Base {
public:
void Method( int a ){};
};
int _tmain(int argc, _TCHAR* argv[]) {
Base b;
b.Method( 1, 2 ); // works
Derived d;
d.Method( 1,2 ); // compiler complains
d.Method( 1 ); // works
return 0;
};
Despite the prototype for each of these methods being different, since the same name has been defined above the rule of Dominance kicks in, and only the base class method is available.
Weird, but part of the spec.
No comments:
Post a Comment