Difference between revisions of "Inheritance"

From CS 61A Wiki
Jump to: navigation, search
[checked revision][checked revision]
(expand definition)
m (add term)
Line 1: Line 1:
'''Inheritance''' is an [[object-oriented programming|OOP]] idea that specializes a class based on a general class. The specialized class ''inherits'' the attributes from the general class but has some special-case behavior. The general class is called the ''superclass'' (or ''parent class'' or ''base class''), while the specialized class is called the ''subclass''.
+
'''Inheritance''' is an [[object-oriented programming|OOP]] idea that specializes a class based on a general class. The specialized class ''inherits'' the attributes from the general class but has some special-case behavior. The general class is called the ''superclass'' (or ''parent class'' or ''base class''), while the specialized class is called the ''subclass'' (or ''child class'').
  
 
== Motivation ==
 
== Motivation ==

Revision as of 13:51, 6 July 2014

Inheritance is an OOP idea that specializes a class based on a general class. The specialized class inherits the attributes from the general class but has some special-case behavior. The general class is called the superclass (or parent class or base class), while the specialized class is called the subclass (or child class).

Motivation

Compared with composition

Method and constructor lookup

Method/attribute overriding