##### Differences

This shows you the differences between two versions of the page.

 cs-142:reference-parameters [2015/10/12 17:06]kseppi created cs-142:reference-parameters [2015/10/13 14:31]kseppi 2015/10/13 14:31 kseppi 2015/10/12 17:06 kseppi created 2015/10/13 14:31 kseppi 2015/10/12 17:06 kseppi created Line 16: Line 16: } } - // reference ​paramenters ​allow us to change the value of something + // reference ​parameters ​allow us to change the value of something // passed to us. But the "​normal function"​ approach is preferred. // passed to us. But the "​normal function"​ approach is preferred. void foo3(int &x) { void foo3(int &x) { Line 22: Line 22: } } - // We can use reference ​paramentes ​to get more than one value back + // We can use reference ​parameters ​to get more than one value back // to the caller. There are other ways to solve this problem, but // to the caller. There are other ways to solve this problem, but - // this approach is use. Probabaly ​not great if you are trying to + // this approach is use. Probably ​not great if you are trying to // get 23 values back. More on that latter. // get 23 values back. More on that latter. void return_more_than_one_thing(int in1, int in2, int &out1, int &out2) { void return_more_than_one_thing(int in1, int in2, int &out1, int &out2) { Line 41: Line 41: // another use of references is to return values and to use // another use of references is to return values and to use // the return only for returning the status of the operation. // the return only for returning the status of the operation. - int divide(double dividend, double divisor, double quotient) { + int divide(double dividend, double divisor, double ​"ient) { if (divisor == 0){ if (divisor == 0){ return 0; return 0;