I have a program that makes different types of accounts (One Account class, and other class inherit from it) , and then my main class goes through a vector of each account and calls its "printInfo" method.
My problem, is that it's only ever calling the virtual method in the class Account, and not in any of its sub-classes that inherit from it.
Here is my code (Shortend so you can see the relative parts;
In the vector you store Account objects so they can't be any other type. You can store pointers in the vector instead and it should work beter vector<Account*> account;
Could you suggest a way for me to store pointers to each account? I understand the basics of pointers, but I'm sure of the best way to go about doing this.
Maybe I should have a vector for <Account*> and one for <Account>? Would I need to do that?
Could I just creata a pointer to an Account, create the account, then make that pointer point to it, then store it in the vector? Would I need to give each account I create a different name as they would over write themselves otherwise?