#include <iostream>
using namespace std;
class Duck {
public:
virtual void quack() = 0;
};
class BigDuck : public Duck {
public:
// void quack(); (uncommenting will make it compile)
};
void BigDuck::quack(){ cout << "BigDuckDuck::Quack\n"; }
int main() {
BigDuck b;
Duck *d = &b;
d->quack();
}
Consider this code, the code doesn't compiles. However when I declare the virtual function in the subclass, then it compiles fine.
The compiler already has the signature of the function which the subclass will override, then why a redeclaration is required?
Any insights.