0

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.

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
YelizavetaYR
  • 1,611
  • 6
  • 21
  • 37
  • its not an exact duplicate, but that aside even if this-> fixes the variables. there is still the error of the empty class: 83:16: error: 'template class Account' used without template parameters. adding a to template the empty class doesn't fix it – YelizavetaYR Dec 01 '16 at 18:41
  • You should add the error message you get to the question. – Quentin Dec 02 '16 at 08:42

0 Answers0