Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Function With Parameters in C++

#include <iostream>
using std::cout;
using std::endl;

int byValue( int ); 
void byReference( int & ); 
                                                   
int main()
{
   int x = 2; 
   int z = 4; 

   cout << byValue( x ) << endl;  
   cout << "x = " << x << endl;

   byReference( z );
   cout << "z = " << z << endl;
   return 0;
} 

int byValue( int number )
{
   return number *= number;
}
void byReference( int &numberRef )
{
   numberRef *= numberRef; 
}