1 / 13

Chapter 11 Class Inheritance

Chapter 11 Class Inheritance. Chapter 11. Inheritance is that property of object-oriented programming that allows one class, called a derived class , to share the structure and behavior of another class, called a base class. Chapter 11. A family of bank account classes. Chapter 11.

tskinner
Download Presentation

Chapter 11 Class Inheritance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11Class Inheritance

  2. Chapter 11 • Inheritance is that property of object-oriented programming that allows one class, called a derived class, to share the structure and behavior of another class, called a base class.

  3. Chapter 11 • A family of bank account classes

  4. Chapter 11 • The important link between a derived class and its base class is the IS-A link. For instance, a checking account IS-A bank account. The IS-A relationship must exist if inheritance is used properly. If there is no IS-A relationship, inheritance should not be used.

  5. Chapter 11 Format for Declaring Derived Classes classderived class : public base class { Derived Class Member Functions Derived Class Member Data }; //END CLASS

  6. Chapter 11 • A protected member of a class is a member that is accessible to both the base class and any derived classes of the base class in which it is declared. Use the keyword protected when declaring a member of a class if you want to allow access to the member by a derived class. The # symbol is used in UML to denote a protected class member.

  7. Chapter 11 • An abstract class is a base class for which objects will never be created.

  8. Chapter 11 • A public base class allows all public members of the base class to be public in the derived class.

  9. Chapter 11 • Single inheritance occurs when the inherited class members can be traced back to a single parent class. • Multiple inheritance occurs when the inherited class members can be traced back to more than one parent class.

  10. Chapter 11 Use #ifndef When Declaring Base Classes in C++, as follows: #ifndefHEADER FILE NAME_H #define HEADER FILE NAME _H BASE CLASS DECLARATION #endif

  11. Chapter 11 • The term polymorphic is Greek meaning “of many forms.” • A polymorphicfunction is one that has the same name for different classes of the same family, but has different implementations, or behavior, for the various classes.

  12. Chapter 11 • Dynamic, or late, binding occurs when a polymorphic function is defined for several classes in a family but the actual code for the function is not attached, or bound, until execution time. • A polymorphic function that is dynamically bound is called a virtual function.

  13. Chapter 11 • Staticbinding occurs when a polymorphic function is defined for several classes in a family and the actual code for the function is attached, or bound, at compile time. Overloaded functions are statically bound.

More Related