returning values from function

Hello,

if I want to return more than one values from function, I should do that through the pointer. But I still dont get it, how can I do that? Could someone be so kind and explain that to me on some example (lets say if I want to return two int values)? Thanks a lot.
That is syntactically illegal. You cannot simultaneously return two values, EVAR. (Unless you create an object or array in which to store those multiple values. I personally consider that a little cumbersome if the only reason is to enable multiple returns but it does have uses, I'm sure.) You can have multiple returns in a function (for example depending on various conditions you might check therein) but you cannot return two values at once.
oh, thanks a lot. I am still messed up with this pointer thing.
...I hear ya ripley...I just finished up a semester of C++ and finally had to give up on pointers...and give it a rest...I think its one of those things that will have to come with time.

...as far as returning mulitple values from a function, like tummy says...you can only return a single value...check out structures, or classes, those allow for you to return an object which can have multiple values...
The typical method of returning several values from a function is not return them at all, and instead pass pointers or references to which the function will write to. For example,
1
2
3
4
5
6
7
8
9
10
11
void rectangular_2_polar(double *angle,double *radius,double x,double y){
    if (x)
        *angle=atan(y/x)
    else if (y>0)
        *angle=pi*.5;
    else if (y<0)
        *angle=pi*1.5;
    else
        *angle=0;
    *radius=sqrt(x*x+y*y);
}
Thanks :)
Topic archived. No new replies allowed.