Program to illustrate Difference between Call by Value & Call by Reference


#include <iostream.h>
#include <conio.h>
void f (int, int &);
void main( )
{
    int a = 22, b = 44;
    cout<<" a = "<<a <<",        b = " <<b<<endl;
    f(a,b);
    cout<<" a = "<<a <<",         b = " <<b<<endl;
    f(2*a-3,b);
    cout<<" a = "<<a <<",        b = " <<b<<endl;
    getch();
}
void f(int x, int *y)
{
    x = 88;
    * y = 99;
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|