Returning By References

Here we are creating X as a global Variable and creating another swap variable as variableret. When we assign value of variableret as 56 then value of x also become the 56

/*Returning By References*/

#include<iostream>

using namespace std;

int x; //global variable

int& variableret(){

return x;

}

int main(){

variableret()=56;

cout<<x;

return 0;}




0 Comments had been done yet:

Post a Comment