fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int foo(const int& a, int & b) {
  5. b += a;
  6. cout << a << endl;
  7. }
  8.  
  9. int main() {
  10. int a = 5;
  11. const int & b = a;
  12. foo(a,a);
  13. foo(b,b);
  14. return 0;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:8: error: binding ‘const int’ to reference of type ‘int&’ discards qualifiers
  foo(b,b);
        ^
prog.cpp:4:5: note:   initializing argument 2 of ‘int foo(const int&, int&)’
 int foo(const int& a, int & b) {
     ^~~
stdout
Standard output is empty