fork download
  1. #include <iostream>
  2. #include <array>
  3.  
  4. using namespace std;
  5.  
  6. class testClass
  7. {
  8. std::array<int, 2> testArray;
  9.  
  10. public:
  11. testClass();
  12. void func() const;
  13.  
  14. };
  15.  
  16. testClass::testClass()
  17. {
  18. testArray[0] = 1;
  19. testArray[1] = 2;
  20. }
  21.  
  22. void testClass::func() const
  23. {
  24. for (int i = 0; i < 2; ++i)
  25. std::cout << testArray.at(i) << '\n' << testArray[i] << '\n';
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31. testClass test;
  32. test.func();
  33. return 0;
  34. }
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
1
1
2
2