2011-10-11 55 views
-1

它說這個功能有問題。它應該從用戶輸入要訂購的線軸數量,然後輸出它收到的輸入。 (想想如果有時間添加確認對話框)。不符合操作人員>>

/********************************************/ 
// Name: inspools       /
// Description: Ask for and get number of /
// spools         /
// Parameters: N/A       /
// Reture Value: spoolnum     /
/********************************************/ 
int spoolnum() 
{ 
    int spoolnum; 

    cout << "Number of spools to be shipped: " << endl; 
    cin >> spoolnum; 
    cout >> spoolnum >> " spool(s) of wire will be shipped" >> endl; 

    return; 
} 

回答

1

你有你的箭頭向後這一行:

cout >> spoolnum >> " spool(s) of wire will be shipped" >> endl; 

它應該是:

cout << spoolnum << " spool(s) of wire will be shipped" << endl; 

而且你return語句需要返回的東西:

return spoolnum; 
+0

謝謝修復這個問題,但現在它說:「錯誤:返回沒有值的語句,在函數返回int」即使我宣佈它。這裏是完整的代碼: –

+0

是的,你的'return'語句需要返回一些東西。試試這個'return 0;' – Mysticial

+0

再次感謝,不知道沒有這個網站我會做什麼。 –

1

是的,就是你 需要使用<<cout

ostream沒有運算符重載爲>>,因此您看到的錯誤。

0

這條線:

cout >> spoolnum >> " spool(s) of wire will be shipped" >> endl;

應該是:

cout << spoolnum << " spool(s) of wire will be shipped" << endl;

1
cout << spoolnum << " spool(s) of wire will be shipped" << endl; 

和你return語句應該返回spoolnum:

return spoolnum;