SHARE
TWEET

Untitled

a guest Jul 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class A {
  2. BasePtr * ptr;
  3. virtual BasePtr * getPtr() { return ptr; }
  4. virtual void pure() = 0;
  5. }
  6.      
  7. class B : public A {
  8. B() : A() { ptr = new RoundPtr(); }
  9. };
  10.  
  11. class C : public A {
  12. C() : A() { ptr = new SquarePtr(); }
  13. }
  14.      
  15. A * list[2];
  16. list[0] = new B();
  17. list[1] = new C();
  18.      
  19. list[i]->getPtr();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top