Refrence Variable In C++

In Oops there are two type of variables
1.Instance Variable
2.Refrence Variable

Instance variable:-Variable which occupy seprate memory in the program is known as instance variable.

Refrence variable:-Variable which do not occupy seprate its just alternative name of instance variable.

Syntax to create Refrance Variable
data type &refrence variable name =existing variable name.

Example

Int a=10;
Int &b=a;

Cout>> a;
Cout>>b;

b=50;

Cout>> a;
Cout>>b;

Output
10
10
50
50.

No comments:

Post a Comment