struct Base{
virtual void foo(){
std::cout << "In Base\n";
}
};
struct Derived : public virtual Base{
virtual void foo() const{
std::cout << "In Derived\n";
}
};
Base* d = new Derived();
int main(int argc,char** args){
d->foo();
system("Pause");
}
When I run this code "In Base" is printed. Why does having the const specifier change the inheritance?