I am working on a program to create two inherited class (savings and checking)from one base class (account) and I have to overload += and-= to work on my defined classes (savings and checking). But I am getting this syntax error and it is driving me crazy.
Right now I am just doing the overload for the Checking class and will add it to the Savings class when done (so I did't include the savings.cpp or savings.h).
In the += overloaded funtion I am just displaying a message and returning this.
But I am guessing that I just need to have a line like this
balance = balance + Right;
ERROR 47 C:\Dev-Cpp\lab7.cpp no match for'operator+=' in '*(&checking)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = Account*, _Alloc = std::allocator<Account*>](((unsigned int)(acct - 1))) += amt'
Oh, ok, now that I looked more closely I see the problem.
You are trying to call Checking::operator+=( double ) because amt is a double, but
you only provide Checking::operator+=( const Checking& ). You need to provide the
former operator as well.
Disch I am not sure what you mean. :( I just was trying to get the += overloaded for the checking and once that was working I would just copy it to use it for the savings object. I thought that since savings and checking were created thru inheritance that they inherited the public member functions of account.
Your vector is declared as a vector of pointers to base classes. You will have to make
a (pure) virtual operator+=( double ) in the base class (Account).