can a fucntion return multiple values ? probabily use of structure may help to return more than one values.
i wrote a code, its giving compile error.
Code:
#include<iostream>
using namespace std;
struct test
{
int flag;
int x;
char y;
};
struct func(); // prototype
int main()
{
struct test d = func();
if (d.flag==1) { cout<<"char returned"; cout<<d.y;}
else
cout<<d.x;
}
struct func()
{
struct test c;
ch='A';
if(ch<127) // checking whetehr ch is a char
{
c.y= ch;
c.flag=1;
return c;
}
else
{
c.x = 100;
c.flag=0;
return c;
}
}
question 1. > why there is error ?
question 2.> how can i fix those error?