#include <iostream>
#include <typeinfo>
using namespace std;

class X { virtual void whatever(){}};
class Y : public X {public: int a;};

int main() {
    try{
      X* x = new X;
      X* y = new Y;
      Y &yy = dynamic_cast<Y&>(*x);
      cout << yy.a;
    } catch(std::exception& e) {cout << e.what() << endl;}
}