When you pass an argument to a function, a copy of that argument is made inside the function. - C++ Function

C++ examples for Function:Function Parameter

Description

When you pass an argument to a function, a copy of that argument is made inside the function.

Demo Code

#include <iostream>
using namespace std;
void f(int a) {
   cout << "a = " << a << endl;
   a = 5;/*from   w  w  w  .  java 2  s .  co m*/
   cout << "a = " << a << endl;
}
int main() {
   int x = 47;
   cout << "x = " << x << endl;
   f(x);
   cout << "x = " << x << endl;
}

Result


Related Tutorials