I am doing my homework in C# in which I dealing with abstract class.
public abstract class Account
{
public abstract bool Credit(double amount);
public abstract bool Debit(double amount);
}
public class SavingAccount : Account
{
public override bool Credit(double amount)
{
bool temp = true;
temp = base.Credit(amount + calculateInterest());
return temp;
}
public override bool Debit(double amount)
{
bool flag = true;
double temp = getBalance();
temp = temp - amount;
if (temp < 10000)
{
flag = false;
}
else
{
return (base.Debit(amount));
}
return flag;
}
}
When I call the base.Debit() or base.Credit() then it gives me an error cannot call an abstract base member.
You cannot call abstract methods, the idea is that a method declared abstract simply requires derived classes to define it. Using
base.Debitis in affect trying to call an abstract method, which cannot be done. Reading your code more closely, I think this is what you wanted forDebit()