| <<< Things to watch out for | Index | More things to watch out for >>> |
An object of a derived type will be implicitly converted to an object of the base type when necessary:
class Base {};
class Derived : public Base {};
void e( Base b );
void f( Base* bp );
void g( Base& br );
void h( Derived* dp );
Base b;
Derived d;
e( d ); // OK, implicit conversion via "upcast"
f( &d ); // OK, implicit conversion
g( d ); // OK, implicit conversion
h( &b ); // Error
| <<< Things to watch out for | Index | More things to watch out for >>> |