Difference between revisions of "Inheritance"

From CS 61A Wiki
Jump to: navigation, search
[checked revision][checked revision]
(created)
 
(expand definition)
Line 1: Line 1:
'''Inheritance''' is a concept in [[object-oriented programming]].
+
'''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''.
  
 
== Motivation ==
 
== Motivation ==

Revision as of 13:49, 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.

Motivation

Compared with composition

Method and constructor lookup

Method/attribute overriding