| <<< Implicit conversion, upcast | Index | Ways to use inheritance >>> |
class Base {};
class Derived : public Base {};
void f( Base* bp );
void g( Base b );
void h( Derived* dp );
Derived d;
Base b;
Base* bp = &d; // OK
f( bp ); // OK
g( b ); // OK
h( (Derived*) bp ); // Accepted, but not advised
h( (Derived*) &b ); // Accepted, but surely wrong!
| <<< Implicit conversion, upcast | Index | Ways to use inheritance >>> |