Call by reference, C/C++ Programming

Call by reference:

Arguments to a function can be passed in two way; one by call by value and other by call

by reference.  Call by value is passed either through a constant or variable.  The call by reference is passed through address operator (&).  In C the function definition argument must be declared as pointer variable to pass by reference, where as in C++ the call by reference can be used without declaring the function arguments as pointer variables.  But in C++ both pointer argument method and without pointer argument can be adopted.

 

void f_ref(int &a, int &b); // void f_ref(int, int) is wrong for reference variable;

void main( )

{int a, b;

f_ref(a, b); // The value a is 10 and b is 20.

 

 

}

void f_ref(int &x, int &y)

{x =10;

y=20;

}

Posted Date: 9/20/2012 7:45:33 AM | Location : United States







Related Discussions:- Call by reference, Assignment Help, Ask Question on Call by reference, Get Answer, Expert's Help, Call by reference Discussions

Write discussion on Call by reference
Your posts are moderated
Related Questions
The continue statement The continue statement causes the next iteration of the enclosing loop to start. When this is encountered in the loop , the rest of the statements in the

#Hi, I''m planning to derive the escape velocity through C++. I would just like to know if it''s possible to differentiate symbolic functions? Do I need to download libraries,etc?

padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanString {     publ

how to create the programs in c++ knowledge

Write a program that keeps record of football results. Program stores following information about each match: Description Type and/or size name of home team max. 25 characters name

how can i write reverse digit function like writing 1234 and printing 4321

how to declare arrays

array itself is a pinter.explain

a program to determine whether a number is an odd or even using recursive function

To develop a web crawler such that when given a base URL, it will traverse the entire web tree and then build an index of keywords and what URL link they appear on.   The web crawl