#include <iostream> using namespace std; void f(int (&a)[10]) { for(int i = 0; i < 20; i++) { cout << a[i] << endl; } } int main() { int a[20]; for(int i = 0; i < 20; i++) { a[i] = i; } f(a); return 0; }
Standard input is empty
prog.cpp: In function ‘int main()’:
prog.cpp:15:4: error: invalid initialization of reference of type ‘int (&)[10]’ from expression of type ‘int [20]’
f(a);
^
prog.cpp:4:6: note: in passing argument 1 of ‘void f(int (&)[10])’
void f(int (&a)[10]) {
^
Standard output is empty