fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Foo {
  5.  
  6. public:
  7. static int count;
  8. Foo() {
  9.  
  10. }
  11.  
  12. Foo(int i) {
  13. std::cout << "I am object no: " << count << std::endl;
  14. count++;
  15. }
  16.  
  17.  
  18. };
  19.  
  20. int Foo::count = 0;
  21.  
  22. int main() {
  23. // your code goes here
  24. std::size_t number;
  25. std::cout << "Enter the number of accounts you want to create: ";
  26. //std::cin >> number;
  27.  
  28. Foo* f[number];
  29.  
  30. for(unsigned i=0; (i < 10); i++)
  31. {
  32. f[i] = new Foo(i);
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Enter the number of accounts you want to create: I am object no: 0
I am object no: 1
I am object no: 2
I am object no: 3
I am object no: 4
I am object no: 5
I am object no: 6
I am object no: 7
I am object no: 8
I am object no: 9