13 lines · cpp
1struct A {2 virtual ~A() {}3};4struct B : public A {};5 6void f() {7 const A *b = new B();8 const B *c1 = dynamic_cast<const B *>(b);9 const B *c2 = static_cast<const B *>(b);10 const B *c3 = reinterpret_cast<const B *>(b);11 A *c4 = const_cast<A *>(b);12}13