Return by reference, C/C++ Programming

Return by reference:

The return value of the function must be an address variable.  In following program the

function returns the value of x or y and their types are declared as reference variable.

 

int &f_ref(int &c, int &d); // int &f_ref(int, int) is invalid for reference variable void main( )

{int a, b,c;

c=f_ref(a, b);

}

int &f_ref(int &x, int &y)

{if x>y return x; else return y;

}

 

 

Posted Date: 9/20/2012 7:46:02 AM | Location : United States







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

Write discussion on Return by reference
Your posts are moderated
Related Questions
Rules of Inheritance: Private members are not inherited; the members can be accessed only within its class. It cannot be used through the object. Protected members are

1.jewels can only be removed for polishing from either end of the necklace. 2.cost of polishing=sitting number*colour value of jewels.

C program to define power of a function: Write a program to use power of a function. void main() { int x,y,po=1,i,j; clrscr();   printf("Give x,y\n"); sca

Just need the answers to the following 3 questions. "NO NEED to write a program compile or run it, do not need it. Just need the answers for the following questions. Example quest

how to use nested loop of for in array

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

I need to program a microprocessor that would have a temperature, gas, humidity and PIR sensor connected to it. It would send the data to a PC via a Zigbee and receive commands fro

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

A: Provide a friend operator class Base { public: friend std::ostream& operator ... protected: virtual void printOn(std::ostream& o) const; }; inline std::ostr

Program to draw a circle: int main(void) {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int midx, midy;    int radius = 100;