I have a templated parent class.
template <class T>
class Account
{
protected:
T balance;
int deposits;
int withdrawals;
T interestRate;
T serviceCharges;
bool status;
public:
...
with several functions (some virtual, others not). I then have an inherited class (two actually) below is an example of one such class. There are a handful of errors coming up that I can't seem to solve.
template <class T>
class Checking : public Account <T>
{
public:
void withdraw(double amt)
{
if (status == false)
{
cout << "Account is inactive.\n\n";
return;
}
try
{
if (amt < 0)
throw Account::NegativeAmount();
else if (balance - amt < 25 && balance - amt > 0)
{
cout << "\nYour account has fallen below $25.00.\n";
cout << "It will be deactivated.\n";
status = false;
}
else if (balance - amt < 0)
{
cout << "You are attempting to withdraw more than the ";
serviceCharges += 15.00;
cout << "account balance.\n";
}
else
Account::withdraw(amt); // base class function call
}
catch (Account::NegativeAmount())
{
cout << "Withdraw positive numbers only.\n";
}
}
};
Another error I'm seeing is error for this declaration/line of code:
code: throw Account::NegativeAmount();
error: 'template<class T> class Account' used without template parameters
If i attempt to fix it by adding
code: throw Account<T>::NegativeAmount();
there is still an error and its not being fixed.