Можно ли вызвать метод из main, если он приватный? Если нет, то как это возможно?
Я пытаюсь запустить эту программу, но в настоящее время у меня просто появляются ошибки. Я не уверен, как заставить это работать. Если я изменю класс SavingsAccount на public, все должно быть в порядке, но я должен сохранить его как есть.
Проблема в основной функции.
#include
#include
#include
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;
}