fork download
  1. #include <iostream>
  2.  
  3. class Abstract
  4. {
  5. public:
  6. virtual void pureVirt() = 0;
  7. };
  8.  
  9. class Derived: public Abstract
  10. {
  11. int a;
  12. public:
  13. Derived(int x):a(x){}
  14. virtual void pureVirt(){std::cout<<"in pureVirt: "<< a <<"\n";}
  15. };
  16.  
  17. void func(Abstract ** b);
  18.  
  19. int main()
  20. {
  21. Abstract * array[3];
  22.  
  23. func(array);
  24.  
  25. array[0]->pureVirt();
  26. array[1]->pureVirt();
  27. array[2]->pureVirt();
  28.  
  29. std::getwchar();
  30.  
  31. return 0;
  32. }
  33.  
  34. void func(Abstract** b)
  35. {
  36. b[0]= new Derived(0);
  37. b[1]= new Derived(1);
  38. b[2]= new Derived(2);
  39. }
Success #stdin #stdout 0.01s 2876KB
stdin
Standard input is empty
stdout
in pureVirt: 0
in pureVirt: 1
in pureVirt: 2