#include<iostream>
struct emp
{
char name[20];
int age;
float sal;
};
emp e1={"Amol",21,2345.00};
emp e2={"Ajay",23,4500.75};
int main()
{
emp &fun();
fun()=e2;
std::cout<<std::endl<<e1.name<<" "<<e1.age<<" "<<e1.sal<<std::endl;
return 0;
}
emp &fun()
{
std::cout<<std::endl<<e1.name<<" "<<e1.age<<" "<<e1.sal<<std::endl;
return e1;
}
I don't understand the working of the above example, is this same as &b = a? How is the value of e2 being passed to &fun()?