Let's say for example we have a base class and a derived class, the base class has a virtual function that is overridden in the derived class.
Is it somehow possible to call the base virtual function from inside the overridden virtual function in the derived class? if so, how can I call that function?
Please look at the code below to see what I mean...
//Here is the base class
class BankAccount
{
protected:
double balance;
int num_of_deposits;
int num_of_withdrawals;
double interest_rate;
double service_charges;
public:
virtualvoid Withdraw (double num)
{
balance -= num;
++num_of_withdrawals;
}
//Here is the derived class
class SavingAccount : public BankAccount
{
bool status;
BankAccount *pointer;
public:
void Withdraw (double num)
{
if (balance > 25)
status == true;
else
status == false;
if (status == true)
Withdraw (num); //is this the proper way to call the base class virtual function? or do i need an object to do that?
else
{
cout << "Your account is not active";
cout << " and therefore you cannot";
cout << " withdraw any money";
cout << endl;
}
}