|
-
May 14th, 2012, 03:20 AM
#1
Returning by reference from function
struct emp
{
char name[20];
int age;
float sal;
}e1 = {"hello", 24, 2345.67}, e2 = {"hi", 34, 45678.89};
void main()
{
emp &fun();
fun() = e2;
cout << endl << e1.name << endl << e1.age << endl << e1.sal;
}
emp &fun()
{
cout << endl << e1.name << endl << e1.age << endl << e1.sal;
return e1;
}
Query: I am unable to get emp &fun() and fun() = e2...
TANUSHREE-AGRAWAL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|