fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Foo {
  5. public:
  6. Foo(int x) { this->x = x; }
  7.  
  8. int x;
  9. };
  10.  
  11. int main() {
  12. Foo tab[5] = {
  13. Foo(0), Foo(1), Foo(2), Foo(3), Foo(4)
  14. };
  15.  
  16. std::cout << tab[2].x << std::endl; // prints '2'
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
2