【发布时间】:2015-11-05 03:35:11
【问题描述】:
BankDatabase 银行是类对象:
class BankDatabase
{
private:
Customer* customers[25];
Account *accounts[25];
int count;
public:
BankDatabase();
Account* getAccount(int accountNum);
Customer* getCustomer(int accountNum);
void display();
void createAccount();
};
class Customer //CUSTOMER CLASS
{
private:
string fullName;
int accountNumber;
string address;
int phoneNumber;
public:
Customer();
Customer(string name, int acc, string add, int phone);
int getAccountNum() const;
string getName() const;
string toString() const;
/*bool Customer::operator> (Customer* a);*/
};
class Account //ACCOUNT CLASS
{
protected:
int accountNumber;
int PIN;
double totalBalance;
public:
Account();
Account(int acc, int P, double bal);
bool validatePIN(int pin);
int getAccountNum() const;
double getTotalBalance() const;
virtual string toString() const;
void credit(double amount);
virtual bool debit(double amount);
/*bool Account::operator> (Account* a);*/
};
函数原型是
void AccountAccess(class bank); //This might be error
在main之前。主要内容:
int main()
{
BankDatabase bank;
int decision;
bool goodInput;
bool isDone = false;
do
{
cout << "Welcome to the Bank of Cthulhu!" << endl;
cout << endl;
do
{
cout << "Please select an option from the main menu: " << endl;
cout << endl;
cout << "1) Create an account" << endl;
cout << "2) Access your account" << endl;
cout << "3) Exit" << endl;
cout << endl;
cin >> decision;
if (decision == 1)
{
//bank.createAccount(); this works
goodInput = true;
}
else if (decision == 2)
{
AccountAccess(bank);
goodInput = true;
}
else if (decision == 3)
{
isDone = true;
goodInput = true;
}
else
goodInput = false;
} while (!goodInput);
} while (!isDone);
return 0;
}
我将银行放入的实际功能是
void AccountAccess(BankDatabase b)
{ //Function that allows the user to access their account
int accInput;
int pin;
bool goodInput;
do
{
cout << "Enter account number or press 1 to return to the main menu: ";
cin >> accInput;
if(b.getAccount(accInput) != 0)
{
goodInput = true;
break;
}
else if (accInput == 0)
{
cout << "Returning to main menu..." << endl;
cout << endl;
goodInput = true;
break;
}
else if (b.getAccount(accInput) == 0)
{
cout << "Account not found. Please try again." << endl;
goodInput = false;
}
} while (!goodInput);
return;
}
给我错误“'void AccountAccess(bank)' cannot convert argument 1 from 'BankDatabase' to 'bank'
我尝试了几种变体,但我不确定如何解决这个问题,我知道这很简单。任何帮助将不胜感激。
【问题讨论】: