ADVERTISEMENT
ADVERTISEMENT

Home » C++ programs » C++ basic programs

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

In this program you will learn how to use function an 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
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.