我试图让这个程序开始运行,但目前我得到的错误。 我不知道如何得到这个工作。 如果我改变类SavingsAccount公众应该没关系,但我必须保持原样。
问题是,在主函数。
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class SavingsAccount
{
int accountType;
string ownerName;
long ssn;
double accountClosurePenaltyPercent, accountBalance;
void Information();
inline double AccountClosureLoss()
{
return (accountBalance * accountClosurePenaltyPercent);
}
void OutputInformation();
};
void SavingsAccount::Information()
{
cout << "Enter Account Type (1 for Checking or 2 for Savings): ";
cin >> accountType;
cout << "Enter owner name: ";
getline(cin, ownerName);
cout << "Enter the Social Security Number: ";
cin >> ssn;
cout << "Enter the percent penalty for closing account(decimal form): ";
cin >> accountClosurePenaltyPercent;
cout << "Enter the account balance: ";
cin >> accountBalance;
}
void SavingsAccount::OutputInformation()
{
cout << "Account Type: " << endl;
cout << "Name: " << ownerName << endl;
cout << "SSN: " << ssn << endl;
cout << "Account Closure Penaly %: " << accountClosurePenaltyPercent << endl;
cout << "Account Balance: " << accountBalance;
}
int main(void)
{
SavingsAccount.Information();
SavingsAccount.AccountClosureLoss();
SavingsAccount.OutputInformation();
return 0;
}
我试过至今。
int main(void)
{
SavingsAccount John;
John.Information();
John.AccountClosureLoss();
John.OutputInformation();
return 0;
}
有什么建议?