Advertisement
Guest User

Untitled

a guest
Mar 12th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. using namespace std;
  5.  
  6. auto main() -> int {
  7.  
  8.     struct A {
  9.         virtual void dosmth() = 0;
  10.     };
  11.  
  12.     struct B : A {
  13.         virtual void dosmth() override {
  14.             cout << 332 << endl;
  15.         }
  16.     };
  17.  
  18.     A *obj = new B();
  19.  
  20.     obj->dosmth();
  21.     B *elm = dynamic_cast<B*>(obj);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement