[Solved]I really need a little bit explain on parameter for function (Please HELP meTwT)
Can someone help me explain why While(StockSelect(stocknum)) need to have 'stocknum' in the parameter of the function 'StockSelect' as it didn't get any input value yet or is there any reasons for doing this?
#My teacher show me this example code for my project
#Thanks for your answer
int inqchoice = ShowStockMenu();
cerr<<"Invalid inquiry choice!"<<endl;
You have provided incomplete information. Without looking at the prototype of StockSelect method it can be difficult to explain. So I am making an assumption here that the prototype of StockSelect function is like this
bool/int StockSelect(int& val).
If the prototype is like this then then the function is updating the value passed as argument by reference inside the function. Since the value is being passed by reference, then whatever modification is made to the value will be reflected back outside the function too. So you initially passed uninitialized stocknum(has garbage value) variable (as val), inside the function if i assign val = 10, then variable stocknum will also get value 10. Why is this done like that is probably the value say 10 is obtained by doing various other calculations and it was not possible or required to assign some initial value to it. At the end the function is returning one of true/false/0/1. If my explanation is wrong then you need to provide information about StockSelect