fork download
  1. #include <iostream>
  2. int main()
  3. {
  4. int arr[5]={};
  5. const int (&)ref=arr[5];
  6. ref[5]={1,2,3,4,5};
  7. for(int i=0;i<5;i++)
  8. std::cout<<ref[i]<<" ";
  9. std::cout<<"\n"<<std::endl;
  10. return 0;
  11. }
  12.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:5:1: error: expected primary-expression before ‘const’
 const int (&)ref=arr[5];
 ^~~~~
prog.cpp:6:1: error: ‘ref’ was not declared in this scope
 ref[5]={1,2,3,4,5};
 ^~~
stdout
Standard output is empty