#include <iostream>using namespace std; int foo(const int& a, int & b) { b += a; cout << a << endl;} int main() { int a = 5; const int & b = a; foo(a,a); foo(b,b); return 0;}
Standard input is empty
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) { ^~~
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!