CSC/ECE 517 Fall 2007/wiki2 10 c4: Difference between revisions
Line 22: | Line 22: | ||
==References== | ==References== | ||
# http://searchsmb.techtarget.com/sDefinition/0,,sid44_gci212351,00.html |
Revision as of 02:47, 22 October 2007
Introduction
Problem
Inheritance vs. delegation. Follow the debate on inheritance vs. delegation. Construct (or, better, cite) examples that show cases where inheritance is better, and cases where delegation is better. Attempt to characterize the situations in which you should employ one or the other.
Inheritance
Inheritance is the process of one class having access to another class's attributes. Inheritance occurs when a class, also called the superclass, is created with generalized methods and attributes, and then another class is created as a subclass to the first class. The subclass provides provides detailed methods and attributes and automatically has access to methods and data members of the superclass. These subclasses can also override the generalized methods of the super class. Sometimes subclasses inherit from more than one super class; the occurrance of this is naturally called multiple inheritance.