pass by reference - In C++, can the caller of a function ensure its arguments won't be modified? -



pass by reference - In C++, can the caller of a function ensure its arguments won't be modified? -

in next c++ code:

int foo(int &x); /* function prototype */ main() { int i=5; foo(i); }

suppose i'm unable alter foo() in way.

is there way, in main(), phone call foo() can't modify i?

give re-create of i. way.

int j = i; foo(j);

c++ pass-by-reference

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -