我正在编写一个程序,它将请求用户输入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