Problem: I am trying to implement a linked list using a class template, however each of my classes that I want in the list all inherit from an Account class. I have attempted to template the linked list class as account however Ive come into errors I can't resolve. Any ideas as to how I can go about this?
The error exists within the customer.cpp class where it says
14 IntelliSense: a value of type "Account *" cannot be assigned to an entity of type "CurrentAccount *" f:\Further C++\Assignment with Templates\Assignment\Customer.cpp 22 9 Assignment
You mention lines that give an error, yet you don't include the source for the functions you're calling on those lines. How can anyone help you? We don't know what your functions really return.
Also, you inherit privately, so no way this is gonna work. You can't access members of Account from CurrentAccount. For you to do any sort of assignment between the 2 classes or for that constructor to work, you need public inheritance, like
1 2
class CurrentAccount : public Account
{
Also, I think you've got your polymorphism the wrong way around. You want to be able to treat a child pointer (or reference, whatever) like it's a parent pointer, not the way round, e.g you want to manipulate pointer to CurrentAccount as if it were pointer to Account, so you can deal generally with Accounts. You don't want to treat an Account * as though it were a CurrentAccount *, what if it's not? A CurrentAccount is always an Account, but not the other way round.