Pass by value, pass by reference, pass by pointers.

Pass by value

Pass by reference

  • have a look at code to understand.
    	#include<iostream>
    	void change_var(int &a) //here a is an reference to variable 'x'
    	{
    	a++;
    	}
    	void main()
    	{
    	int x=20;
    	std::cout<<change_var(x)<<x; //here value 20 is in x, and x is referenced by parameter/alias 'a'. the changes will be made in parameter 'a' and in variable 'x', it will generate output as : 21 21
    	}