Independent Reference In C++
C++
language of variable to reference form
one or two variable use to pass.
In independent reference for normal variable
to use value of reference variable to assign it. If normal variable have any
kind of change then reference variable value will change automatic. So like that any kind of
variable to reference value can change at any time, so this type of concept is
known as independent reference.
Fig: Independent Reference In C++ |
Syntax:
datatype variablename;
datatype
&variable=normal variable;
Example:
int
a;
int
&b=a;
Program:
#include<iostream.h>
#inlcude<conio.h>
void
main()
{
int a;
int
&b=a;
cout<<”input
value”;
cin>>a;
cout<<”a=”<<a;
a++;
cout<<”b=”<<b;
b++;
cout<<a;
getch();
}
Output:
Input
value 45
46
47
No comments:
Post a Comment