I am trying to experiment with runtime polymorphism in C++. Can someone explain me the output of this program? I ran it and it gave me an output of Derived (meaning, the function f() of the derived class is called).
Also, what is the expected behaviour of the program if I uncomment the statement - d.f(); ?
// Example program
#include <iostream>
#include <string>
class Base {
    public :virtual void f(int a = 7){std::cout << "Base" <<std::endl;}
};
class Derived : public Base {
    public :virtual void f(int a) {std::cout << "Derived" <<std::endl;}
};
int main() {
    Derived d;
    Base& b = d;
    b.f();
    //d.f();
    return 0;
}
 
     
    