fork download
  1. #include <iostream>
  2. #include <array>
  3.  
  4. using namespace std;
  5.  
  6. void print(array<int, 3> arr) {
  7. for (auto val : arr) {
  8. cout << val << " | ";
  9. }
  10. }
  11.  
  12.  
  13. int main() {
  14.  
  15. array<int, 5> arr = { 1, 2, 3, 4, 5 }; // array<int, 5> != array<int, 3>
  16.  
  17. print(arr);
  18.  
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 15232KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17:11: error: could not convert ‘arr’ from ‘std::array<int, 5ul>’ to ‘std::array<int, 3ul>’
  print(arr);
           ^
stdout
Standard output is empty