returning multiple values from a function

hi, im trying to pass 3 variables from a function to main() but only the very last variable is being transferred. Can anyone give me a hint as to why?

thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main(){
    double mn, avg, mx, dev;
    (mn, mx, avg)=MinMaxAvg(pdata);


    cout<<"\n\nFrom "<<filename<<" your data statistics are:";
    cout<<"\n\n     Count: "<<data.size();
    cout<<"\n   Minimum: "<<mn;
    cout<<"\n   Average: "<<avg;
    cout<<"\n   Maximum: "<<mx;
    cout<<"\n    StdDev: "<<dev;
return 0;
}

double MinMaxAvg(vector <double> *pdata){
    double mnf=2.5,mxf=2.5,avgf=0;
    \\stuff happens
    return mnf, mxf, avgf;
}
Last edited on
the styte of function call is wrong(mn, mx, avg)=MinMaxAvg(pdata);
no more than one valve can be returned from function.

also the function implementation is wrong. you can only return one double value from MinMaxAvg

thank you for the response mzzz, iv been looking this for a while but i just cant figure out where to go from here. if i do..
1
2
3
4
5
6
7
8
void MinMaxAvg(vector <double> *pdata),double& mn, double& mx, double& avg){
    double mn=2.5,mx=2.5,avg=0;
    \\stuff happens
    }

//then back in main()

MinMaxAvg(pdata, mn, mx, avg);


i get a annoying error "error: expected unqualified-id defore 'double'

Thanks
Last edited on
i got it, thanks for your help.
Topic archived. No new replies allowed.