fork download
  1. #include <iostream>
  2. #include <tuple>
  3. #include <type_traits>
  4. #include <array>
  5.  
  6. class Foo{
  7. public:
  8. Foo(){std::cout << "hi\n";}
  9. int x;
  10. };
  11.  
  12. int main() {
  13. std::cout << "with braces:\n";
  14. std::array<Foo, 5> with{};
  15.  
  16. std::cout << "without braces:\n";
  17. std::array<Foo, 5> without;
  18.  
  19. int y;
  20. std::cout << "y: " << y << "\n";
  21.  
  22. for (int i = 0; i < 5; i++)
  23. {
  24. std::cout << "with: " << with[i].x << "\n";
  25. }
  26. for (int i = 0; i < 5; i++)
  27. {
  28. std::cout << "without: " << without[i].x << "\n";
  29. }
  30. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
with braces:
hi
hi
hi
hi
hi
without braces:
hi
hi
hi
hi
hi
y: 0
with: 1
with: 0
with: 2
with: 0
with: -1678916664
without: -381658336
without: 5405
without: 0
without: 0
without: 1320555376