send output through a refernce parameter

i wrote this program that finds the smallest of three int numbers

but im confused on what the second part of the question is asking,
basically i have to modify my minValue function to send its output through a
reference parameter.
im guessing its something like this but im not exactly sure

1
2
void minValue(int& first, int& second, int& third);// function prototype
minValue(first, second, third) // function call 


this is the original code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 #include <iostream>
using namespace std;

int minValue(int first, int second, int third);// function prototype

int main()
{
    int  one, two, three;
    int  min;

    cout << "Input three integer values. Press return." << endl;
    cin  >> one  >> two  >> three;
    min = minValue(one, two, three); // function call 
    cout  << "The minimum value of the three numbers is " << min << endl;
	system("pause");
    return 0;
}

int  minValue(int first, int second, int third)// function definition with 
{
    if (first <= second && first < third)
	{
		return first;
	}
    else if (second <= first && second < third)
	{
		return second;
	}
    else
	{
		return third;
	}
}
Hey,
yeah thats the correct way to pass by reference.
I don't understand why you would want to pass byref though because no values are changed and the function already works as it is ?
Maybe your professor is asking you to add an additional parameter instead of returning a value.
1
2
3
4
//so instead of 
min = minValue(first,second,third);
//you do
minValue(first,second,third,min);  //min is passed by reference 
well i think it was just to test if we knew how to, i was just confused since it asked to send the output through a reference parameter
Topic archived. No new replies allowed.