As keskiverto said, this seems a really odd (read bad) way of designing the classes. Why? Customer and Account have nothing in common apart from a link (a Customer Has Accounts). In fact, the only common data is perhaps 'address' - both have addresses, and maybe a name although they are two different types of names. They are not good candidates for inheritance, and if you try to force it, you'll run into problem after problem, because it's illogical.
Inheritance is not generally used for a mere 'x has a y' relationships. It's more appropriate when it's a 'x is a type of y' relationship. I know this doesn't help with your assignment, but I'm surprised a teacher would suggest it.
What you would normally do in this case is create two completely separate classes - Customer and Account. Then, in Customer, you would maintain an array or vector of Accounts the customer has (its collection) eg.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include "account.h"
class Customer {
string name;
string street;
string suburb;
int customerType; // eg. 1 - personal, 2 - corporate etc.
Accounts accounts std::vector<Account>;
//etc.
public:
getName(int customerId);
getAccount(int accountNum);
// etc.
}
|
The easiest way to remember it is to go back to the basic standard example:
Dog IS A TYPE of Animal = inheritance. Dog gets all Animals methods/properties, (eg. typeOfAnimal = mammal) and adds its own eg. Bark();.
Zoo HAS Animals = not inheritance, just a collection of Animals.
Any basic C++ book willl explain when it's best to use inheritance, and when it's best to just have class members that refer to 'HAS A' relationships, via an array or a vector.