= =这变量名..好长了...哈哈
是这样子的, int accountBalance;
string presentAccountBalance;
string initialBalance;
string deposit;
string money;这些应该都作为类的成员变量,
而且在你的程序里也没看到你用你写的成员函数了啊
类最后的} 后要加;
===========
建议你好好看看书上的例子把,这代码写的不合理
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::string;
class Account
{
double accountBalance;
double presentAccountBalance;
double initialBalance;
double deposit;
double money;
public:
Account()
{ cout<<"please enter the initial balance for the account:"<
if(initialBalance>=0)
accountBalance=initialBalance;
if(initialBalance<0)
{ accountBalance=0;
cout<<"the initial balance was invalid"<
}
void Credit()
{
cout<<"please enter the deposit for the account:"<
presentAccountBalance=accountBalance+deposit;
}
void debit()
{
cout<<"please enter the money you want to take out from account:"<
if(money<=accountBalance)
presentAccountBalance=accountBalance-money;
if(money>accountBalance)
{
presentAccountBalance=accountBalance;
cout<<"Debit amount exceeded account balance"<
}
void getBalance()
{
cout<<"the present account balance is:"<
};
int main()
{
Account account1;
Account account2;
account1.Credit();
account1.debit();
account1.getBalance();
account2.Credit();
account2.debit();
account2.getBalance();
return 0;
}
class后加了一个分号,结果四十几个错误。。。改还不如直接写一个了