fork download
  1. #include <iostream>
  2. #include <initializer_list>
  3. #include <algorithm>
  4. #include <cassert>
  5.  
  6. struct testclass
  7. {
  8. int n[10] = {};
  9.  
  10. testclass(std::initializer_list<int> l)
  11. {
  12. auto end = l.size() <= 10 ? l.end() : l.begin() + 10;
  13. std::copy(l.begin(), end, n);
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. testclass t{ 1, 2, 3, 4, 5, 6 };
  20. for (unsigned i = 0; i<10; ++i)
  21. std::cout << t.n[i] << '\n';
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1
2
3
4
5
6
0
0
0
0