我正在編寫一個程序,它將請求用戶輸入INT,並將其存儲在[10]的數組中。我希望能夠讓用戶選擇DISPLAY選項並查看數組中的所有數據。我只是想不通,這裏是我到目前爲止有:關於將輸入存儲到字符串中,並使用cout來顯示它
case 2 : {
int SamtW;
cout << " Please enter how much you would like to withdraw "<< endl;
cin >> SamtW;
sa.doWithdraw(SamtW);
break;
}
這裏是正在調用的函數上面:
int saving:: doWithdraw(int amount)
{
for (int i = 0; i < 10; i++)
{
last10withdraws[amount];
}
if (amount > 1)
{
setBalanceW(amount);
}
else {
cout << " ERROR. Number must be greater then zero. " << endl;
}
return 0;
}
我相信這將會把用戶輸入到字符串last10withdraws。然後我希望用戶能夠調用此函數:
string saving::display()
{
last10withdraws[10];
return 0;
}
並且這將有望顯示數組的內容。關於我做錯什麼的想法?
什麼的在'doWithdraw'循環的目的是什麼?它現在沒有意義。 – stardust
我希望它把int amount的參數放入數組last10withdraws中。 – Dolbyover
這並非如此,但可以等待。 **你想放哪?在整個陣列?我的意思是陣列中的所有10個位置?** – stardust