fork download
  1. #include <iostream>
  2. #include <cassert>
  3.  
  4. class CLASS_hoge
  5. {
  6. private:
  7. int i_;
  8.  
  9. public:
  10. CLASS_hoge() : i_(-1) { }
  11. void input(int i) { i_ = i; }
  12. void output()
  13. {
  14. assert(0 <= i_);
  15. std::cout << i_ << std::endl;
  16. }
  17. };
  18.  
  19. int main()
  20. {
  21. int n = 0;
  22. std::cin >> n;
  23. assert(0 < n && n < 10);
  24.  
  25. CLASS_hoge **cl = new CLASS_hoge*[n];
  26. int j = 0;
  27.  
  28. for(int i = 0; i < n; i++)
  29. {
  30. cl[i] = new CLASS_hoge();
  31. cl[i]->input(j);
  32. j += 100;
  33. }
  34.  
  35. for(int i = 0; i < n; i++) { cl[i]->output(); }
  36.  
  37. for(int i = 0; i < n; i++) { delete cl[i]; }
  38. delete[] cl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 3432KB
stdin
5
stdout
0
100
200
300
400