C Programming - Dynamic Pointer Cast vs Dynamic Reference Cast

Only difference is that in case of bast casts to references a suitable handler can be provided.

Like the one below


try {
A &a = dynamic_cast < A & >(b); // suppose that this fails
}
catch (bad_cast) {
// do what ever you want
}

Labels:


About this entry