So i have class X with a list of <ClassY*> (There are classes inheriting from Y) and i want to write a function that returns the list (A member function of class X). What should it return?
p.s Class Y is a friend class of class X (And also class X is a friend of class Y)
each customer has a list of apartment, and each apartment has to know what customer owns it
That seems like a bad design-decision to me. Think about it: A customer owns an apartment, the apartment itself doesn't need to know who owns it, in fact, an apartment can't really know who owns it because, well, it's an apartment.
Suppose that the apartment has a doorbell which requires the owners name, you would think "then the apartment needs to know the owner". Wrong, the owner puts his own name on the doorbell of his apartment.
a.doorbell.name = name; //the customer puts his name on the doorbell
Hope that makes sense to you. Let us know if you require any further help.