Returning Reference In C++
If
the reference variable is return type so function should returning reference we
have a value which can replace form one place to another place so there we have to use assignment operator.
Fig:Returning Reference In C++
Fig:Returning Reference In C++
Syntax:
returntype
&functionname (&argument list)
{
function
of body;
}
Program:
#include<iostream.h>
#include<conio.h>
char
&replace(int a);
char
name[30];
void
main
{
cout<<”input
string”;
cin>>name;
replace
(5)=’c’;
cout<<name;
getch();
char
&replace(int a)
{
return
name[a];
}
Output:
Input
value
Pramod
Pramcd
No comments:
Post a Comment