Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ucsfcgl!cca.ucsf.edu!ucsfmis!peterli From: peterli@ucsfmis.ucsf.edu (Peter Li) Newsgroups: comp.lang.c++ Subject: Re: Inheritance vs. Composition Message-ID: <2775@ucsfcca.ucsf.edu> Date: 21 Feb 90 01:16:15 GMT References: Sender: news@cca.ucsf.edu Reply-To: peterli@mis.ucsf.edu (Peter Li) Organization: Univ. of Calif. San Francisco, Medical Information Sciences Lines: 23 In article gza@mentor.cc.purdue.edu (William R Burdick) writes: >The difference between inheritance (or generalization) and composition >(or aggregation) is a tough point to figure out without some good >examples (I hope I can give some here). > ...[deleted] >In OOPLs, you can use instance variables for the part-of relationship >and you can use subclassing for the is-a relationship. Here is a monkey-wrench: Consider the classes INTEGER and RATIONAL, would you say RATIONAL inherit from INTEGER, or RATIONAL is completely independent but composed of two INTEGERs, or ... INTEGER is a subset of RATIONAL (something that OOP doesn't address) ? You can extend this into REALs and COMPLEXes. Figuring out mathematical semantics vs. representations is sure messy ... :-). Peter Li