What is meant by return by reference? How can we return values by reference by using reference variable? Illustrate with examples.


This answer is not selected as best answer. This answer may not be sufficient for exam.

Your limit has been exceed. We have implemented this system because, We got difficulty on managing our servers. Please donate some amount to remove this limit.

Quota: 0 / 30


A C++ function can return a reference in a similar way as it returns a pointer.

When a function returns a reference, it returns an implicit pointer to its return value. This way, a function can be used on the left side of an assignment statement.

The syntax of return a reference is

dataType& functionName(parameters);

let’s take an example that will return a reference

#include <iostream>
using namespace std;

int number;

int& retByRef(){
    return number;

int main(){
	retByRef() = 2;

    cout << number;

	return 0;
If you found any type of error on the answer then please mention on the comment or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .