void Account::getBalance
{
return balance;
}
....void 怎么能返回呢?
Account.h
#include
using std::string;
class Account
{
public:
Account( int ); //构造函数
void credit( int ); // 银行存款
void debit(); // 取钱
int getBalance( int ); //返回当前余额
private:
int balance;
};
Account.cpp
#include
using std::cout;
using std::cin;
using std::endl;
#include "Account.h"
Account::Account( int balance)
{
credit( balance );
}
void Account::credit( int balnace )
{
int money; //加入的金额
int total; //总数和慎搜
total = total + money;
}
void Account::debit()
{
int drawout; //取款的金额
int balance; //余额孝尺
if (drawout
balance = balance - drawout;
}
else
cout<唤历<"Debit amount exceeded account balance!";
}
int Account::getBalance
{
return balance;
}
Account2.cpp
#include "Account.h"
int main()
{
Account myAccount;
int balance;
myAccount.credit( balance );
myAccount.debit( );
return 0;
}
getBalance的返回值帆键是void 但又return了
int getBalance( int ); //埋轿灶返回当前余弯扮额
int Account::getBalance
{
return balance;
}