in reply to Re^2: Perl OOP help for OOP newbie
in thread Perl OOP help for OOP newbie
Inheritance is for "is a" relationships. For instance, a BMW "is a" SportsCar, so BMW could inherit from SportsCar. Now let's try it with your class: An Account "is a" User. That isn't true, so Account would not inherit from User.
"Composition" is for "has a" relationships. For instance, a User "has a(n)" Account. In your case, composition would involve assigning an Account object to a User variable. If your User object uses a hash internally, then one key in the hash could be called ACCOUNTS, and its value could be a reference to an array. The array would contain various Account objects.
|
|---|