×

C++ Programs

C++ Most popular & Searched Programs

C++ Basic I/O Programs

C++ Constructor & Destructor Programs

C++ Manipulators Programs

C++ Inheritance Programs

C++ Operator Overloading Programs

C++ File Handling Programs

C++ Bit Manipulation Programs

C++ Classes & Object Programs

C++ program to use function as a LVALUE using reference variable

Learn, how can we use function as a LVALUE in C++ using the reference variables?
[Last updated : March 01, 2023]

In this program you will learn how to use function as a LVALUE in C++ programming language.

function as a LVALUE using reference variable example in C++

/*C++ program to use function as a LVALUE using reference 
variable.*/
 
#include  <iostream>
using namespace std;
 
int var ;
 
int& fun()
{
    return var;
}
 
int main()
{
    //Function used as LVALUE
    fun() = 10;
 
    cout << "Value of var : " << var << endl; 
 
    return 0;
}

Output

Value of var : 10

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.