fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base {
  5. private:
  6. int* array;
  7. public:
  8. Base(int* a) {
  9. array = a;
  10. for(int i = 0 ; i < 10 ; i++) {
  11. array[i] = i;
  12. }
  13. }
  14. };
  15.  
  16. class Child : public Base {
  17. private:
  18. int* array;
  19. public:
  20. Child() : Base(array = new int[10]) {}
  21. void print() {
  22. for(int i = 0 ; i < 10 ; i++) {
  23. cout << array[i] << endl;
  24. }
  25. }
  26. };
  27.  
  28. int main() {
  29. Child c;
  30. c.print();
  31. return 0;
  32. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9