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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -