Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  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();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement