I am trying to get this program to start running but currently I just get errors. I am not sure how to get this to work. If I change the class SavingsAccount to public it should
Since you cannot change the SavingsAccount class, and since it prohibits access to it's members (private
is the default), you are not supposed to use any menber of that class.
"The problem is in the main function": no, it is in the design of your class. A class with nothing public is not useful.
There is no clean solution to your problem.
A solution on the borderline of changing the class would be in defining an 'interface', and making the (unchanged) class inherit that interface:
class Account {
public:
virtual ~Account(){}
virtual void Information() = 0;
virtual double AccountClosureLoss() = 0;
virtual void OutputInformation() = 0;
};
class SavingsAccout : public Account {
... body remains unchanged
};
The main
will use Account
iso SavingsAccount
:
SavingsAccount savingsAccount;
Account& account = savingsAccount;
// should be accessible via the `Account` interface.
account.AccountClosureLoss();