Re: Difference between Inheritance and containment of an object
Chris Dobson <[email protected]>
| Newsgroups | gmane.comp.programming.cppug |
|---|---|
| Message-ID | <[email protected]> |
The two are similar in many ways, and the choice is often a preference based on how you view the model you are using. If you wish to inherit or contain class X, the inherting class "is a" class X, the containing class "has a" class X. If I am creating a group of very similar classes, that are based on a generic class, inheritance works well. ie. customer class inherits from person class, since every customer is a person. Presumeably, every person has a name, so every customer will have a name. If I want some of the functionality of a class, I may contain an object of that class. ie. corporate client contains a customer class so it can use the customer.address property, but since it is considerably different from a customer it will not use many of the other customer properties. Chris --- vignesh kumar <[email protected]> wrote: > hi friends... > can u pls give me the difference between > inheriting a class to another class and adding a > object of another class into a class as a private > data member.. > > vignesh. > > > --------------------------------- > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/EbFolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/