fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A{};
  5. class B{};
  6.  
  7.  
  8. int main() {
  9. // your code goes here
  10. A *a;
  11. B *b = (B*)a;
  12.  
  13. B *b2 = reinterpret_cast<B*>(a);
  14.  
  15. //err: error: invalid static_cast from type ‘A*’ to type ‘B*’
  16. //B *b3 = static_cast<B*>(a);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty