Q:

C++, how base object downcast to derived object?

Question about downcast from base class to derived class, following the example:
with (2)(3)(4), help to explain the difference between pointer and reference futher?
with (3), how to explain the error information given by g++;
class Base {};
class Derived : public Base {};

int main ()
{
    // example (1)
    Derived d;
    Base* b = &d; // its ok, implict

    // example (2)
    Derived d;
    Base* b = &d;
    Derived* d2 = (Derived*)b; // its ok!

    // example (3)
    Derived d;
    Base& b_ref = d; // its ok, implict
    Derived& d_ref1 = (Derived)b_ref; // error, error: no matching function for call to `Drievd::Drievd(Base&)'

    // example (4)
    Derived& d_ref2 = *((Derived*)(&b_ref)); // its ok
}

A:

// example (2)
Derived d;
Base* b = &d;
Derived* d2 = (Derived*)b; // its ok!

B is a pointer to a Base, you can explicitly cast it to a pointer to a Derived, so long as it's actually the correct type. Since a C-style cast doesn't do a dynamic_cast as part of its attempted conversion, you shouldn't do a C-style cast if there's a chance of failure and your classes are actually polymorphic.
// example (3)
Derived d;
Base& b_ref = d; // its ok, implict
Derived& d_ref1 = (Base)b_ref; // error, error: no matching function for call to `Drievd::Drievd(Base&)'

You aren't casting to a reference, (Base)b_ref creates a new temporary Base object by copying the relevant parts which are referred to by b_ref. The error is because you can't bind a Derived reference to a Base without a cast, so the compiler tries to create a temporary Derived object, but there is no such constructor on Derived. Even if there was such a constructor, it still won't work since the lvalue reference you define is non-const, and cannot bind to a temporary object.
// example (4)
Derived& d_ref2 = *((Derived*)(&b_ref)); // its ok

This works the same as example (2), except you also dereference the newly converted pointer value, thus obtaining an lvalue reference to a Derived object, which happily binds to d_ref2

