CSC/ECE 517 Fall 2007/wiki2 10 c4

From Expertiza_Wiki
Jump to navigation Jump to search

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.

Delegation

Inheritance vs Delegation

Similarities

Differences

Examples

References