function - c++ program for address and variables -
the output code :
9
and i'm not sure change in function add1
, &n mean , when assign i
&n
#include <iostream> using namespace std; int add1(int &n){ n++; return n; } int main(){ int m = 0; (int = 0; < 5; i++){ m += add1(i); } cout << m ; cout << "\n\n"; return 0; }
when &
used in parameter list, cause parameter passed reference function.
what means n
in function add1
, point same space in memory i
in main
function. changes n
reflected in i
, act different names same thing.
Comments
Post a Comment