使用正确的操作数

Using the correct operand

本文关键字:操作数      更新时间:2023-10-16

我正在尝试实现一个从帐户获取余额并减去给定金额的系统。这是我的方法。

transaction withdraw(double amount, double ID){
Account Temp(NULL,NULL,NULL,NULL,NULL);
Temp = Llist.search(ID);  //Returns an Account Objet
Temp.setBalance(Temp.getBalance - amount); //Here is the error, '-' illegal, left operand   has type 'double (_thisCall Account::* )(void)'
string t = "Withdraw";
    transaction trans(t, amount, ID, name);
return trans;
}

我问我会在行中放入哪个操作数,以正确减去"Temp.getbalance"中的"a"

不要忘记函数调用的括号 - 否则你试图从函数指针中拿走一个双精度!

Temp.setBalance(Temp.getBalance() - amount);