這是我的程序的一部分,我需要返回長度的值返回主 任何幫助?如何從void函數返回值?
void getLength(double length)
{
cout << "Enter the length: ";
cin >> length;
if (length < INVAL){
cout << "Do not accept negative values for length. Try again: ";
cin >> length;
}
return length;
}
....
int main()
{
double length = 0;
double width = 0;
double area = 0;
getLength(length);
getWidth(width);
calcArea(length, width, area);
printData(length, width, area);
}
a)無效,b)引用,c)指針... – deviantfan 2014-10-28 22:55:45
爲什麼不將返回類型從'void'更改爲'int'? – taocp 2014-10-28 22:56:17
這會返回值嗎? – Jake 2014-10-28 22:57:44