With References, You Don't Need Pointers! - C++ Function

C++ examples for Function:Function Parameter

Description

With References, You Don't Need Pointers!

Demo Code

#include <iostream> 

using namespace std; 

void myFunction(int &myparam) 
{ 
  myparam = myparam * 2 + 10; /*from  w  w  w .  j  ava2  s .  c om*/
} 

int main() 
{ 
  int mynumber = 30; 
  myFunction(mynumber); 
  cout << mynumber << endl; 
  return 0; 
}

Result


Related Tutorials