---
title: "How to return a reference in c  ?"  
description: "How to return a reference in c  ?"  
author: "Anonymous User"  
published: 2013-06-14  
updated: 2013-06-15  
canonical: https://www.mindstick.com/forum/1109/how-to-return-a-reference-in-c  
category: "visual c++"  
tags: ["visual c++"]  
reading_time: 1 minute  

---

# How to return a reference in c  ?

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),\
How to return a [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) in [c++](https://www.mindstick.com/blog/745/array-in-c-plus-plus)?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

A function can return a reference.Returning a reference can be very useful when you are overloading certain types of operators.However,it also can be employed to allow a function to be used on the left side of an assignment statement.\
e.g.\

```
int &f( )//return a referenceint x;int main( ){f( )=100; //assigning 100 to reference returned by f()cout<< x <<"\n";return 0;}//return an int reference.int &f(){return x;  //return a reference to x}
```


---

Original Source: https://www.mindstick.com/forum/1109/how-to-return-a-reference-in-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
