I have a Rabbit struct, and CrazyRabbit struct that inherits it. When I execute this code:
#include <iostream>
using namespace std;
struct Rabbit {
    virtual void sayCry() { 
        cout << "..." << endl; 
    } 
};
struct CrazyRabbit : Rabbit { 
    void sayCry() { cout <<"Moo"<< endl; }
};
void foo(Rabbit r, Rabbit* pr, Rabbit& rr) { 
    r.sayCry();
    pr->sayCry(); 
    rr.sayCry();
}
int main(int argc, char *argv[]) {
    Rabbit *pr = new CrazyRabbit(); 
    foo(*pr, pr, *pr);
}
I have the results:
...
Moo
Moo
Why the first case executes the method in super class? Is there any rule for execution defined in C++?
 
     
    