std::bad_cast (3) - Linux Manuals
std::bad_cast: std::bad_cast
NAME
Synopsis
Defined in header <typeinfo>
class bad_cast : public std::exception;
An exception of this type is thrown when a dynamic_cast to a reference type fails the run-time check (e.g. because the types are not related by inheritance), and also from std::use_facet if the requested facet does not exist in the locale.
std-bad cast-inheritance.svg
Inheritance diagram
Member functions
constructor (public member function)
Inherited from std::exception
Member functions
destructor destroys the exception object
[virtual]
what returns an explanatory string
[virtual]
Example
// Run this code
Possible output: