Today I have found something which really surprised me:
#include <iostream>
using namespace std;
class A {
public:
virtual void reset() = 0;
};
class B : public A {
public:
virtual void reset() override {
cout << "reset()";
}
};
class C : public B {
public:
void reset(int r) {
cout << "reset(" << r << ")";
}
};
int main()
{
C c;
c.reset();
return 0;
}
If I try to compile the code as is, the compiler complains about reset()
not matched. However if I comment reset(int r)
out, reset()
is miraculously found. How is this possible? There isn't a signature conflict or whatever so why is this happening?