fork(1) download
  1. #include <iostream>
  2.  
  3. struct A
  4. {
  5. int i;
  6. int j = 42;
  7. A(int foo) : i(foo) {}
  8. A() = default;
  9. };
  10.  
  11. void non_array() {
  12. }
  13.  
  14. int main() {
  15. std::cout << "Compiler version: " << __VERSION__ << '\n';
  16. {
  17. // non-array case
  18. A a{};
  19. std::cout << "non-array:" << a.i << ' ' << a.j << '\n';
  20. }
  21. {
  22. // array case
  23. A foo[3] = {A(13), {}};
  24. std::cout << "array (with {}): " << foo[1].i << ' ' << foo[1].j << '\n'
  25. << "array (without): " << foo[2].i << ' ' << foo[2].j << '\n';
  26. }
  27. }
  28.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Compiler version: 4.8.1
non-array:0 42
array (with {}): 0 42
array (without): 0 42