Cpp-Program for return by reference

 Advanced C++ : Introduction to C++ & C++ Structures | by Khushboo Patel |  Medium

//program for return by reference

#include<iostream>

#include<conio.h>

int main()

{

    clrscr();

    cout<<"\n\t\t\tOUTPUT";

    cout<<"\n\t\t\t------";

    int x=10;

    //ref is 0 reference to x;

    int &ref=x;

    ref=20;

    cout<<"\n\t\t\tx="<<x<<endl;

    x=30;

    cout<<"\n\t\t\tref="<<ref<<endl;

    getch();

    return 0;

}

 

                                OUTPUT

                                -----------

                                X=20

                                ref=30

Comments

Popular posts from this blog

DS - Representation of linked list in memory.

Cpp- Program for call by reference

NUMERICAL ABILITY