I'm having trouble fully understanding overriding virtual functions in C++ and what exactly happens when such functions are called.I'm reading PPP using C++ by Bjarne Stroustrup and he provides following example to show off overriding and virtual functions:

```
struct B {
    virtual void f() const { cout<<"B::f; }
    void g() const { cout << "B::g"; }        //not virtual
};

struct D:B {
        void f() const { cout<<"D::f"; } //overrides B::f
        void g() { cout<<"D::g"; }
};

struct DD:D {
        void f() { cout<<"DD::f"; }
        void g() const { cout<<"DD::g";}    
};

void call(const B& b) {
    //a D is kind of B, so call() can accept D
    //a DD is kind of D and a D is a kind of B, so call() can accept a DD
    b.f();
    b.g();
}

int main() {
    B b;
    D d;
    DD dd;

    call(b);
    call(d);
    call(dd);

    b.f();
    b.g();
    d.f();
    d.g();
    dd.f();
    dd.g();
}

```

Output: `B::f B::g D::f B::g D::f B::g B::f B::g D::f D::g DD::f DD::g`

I understand how call(b) outputs `B::f B::g` that is straightforward.

Now `call(d)`. I don't quite understand why but it seems that `call()` can take derived classes of `B` as an argument. Ok. So in `call()` , `b.f()` becomes `d.f()`, since `D::f` overrides `B::f` . Indeed output says `D::f`. But `D::g` doesn't override `B::g` and for the reasons I can't understand it seems to me that `D::g` is having no effect when `call(d)` is executed -- outputs `B::g` in this case.

Next, we execute `call(dd)` which outputs `D::f B::g` . Applying the same logic(?) as above it's clear that `DD::f` doesn't override `D::f` -- not const -- and `DD::g` doesn't override neither `D::g` nor `B::g` since neither are `virtual`.

What happens next bewilders me. Each individual call of `b.f()` , `b.g()` , `d.f()`, `d.g()`, `dd.f()`, `dd.g()` outputs result as if overriding didn't exist at all!
For example, how could `d.g()` output `D::g` when just seconds ago `d.g()` in call() output `B::g` ?
Another, how could `dd.f()` output `DD::f` when in `dd.f()` in `call()` output `D::f` ?

It's safe to say I'm missing something big here, and for that I need help.