fork download
  1. #include <iostream>
  2. int main()
  3. {
  4. int arr[5]{};
  5. const int (&)ref=arr[5];
  6. for(int i=0;i<5;i++)
  7. std::cout<<ref[i]<<" ";
  8. std::cout<<endl<<std::endl;
  9. return 0;
  10. }
  11.  
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:7:12: error: ‘ref’ was not declared in this scope
 std::cout<<ref[i]<<" ";
            ^~~
prog.cpp:8:12: error: ‘endl’ was not declared in this scope
 std::cout<<endl<<std::endl;
            ^~~~
prog.cpp:8:12: note: suggested alternative:
In file included from /usr/include/c++/6/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/6/ostream:590:5: note:   ‘std::endl’
     endl(basic_ostream<_CharT, _Traits>& __os)
     ^~~~
stdout
Standard output is empty