Chapter 11 Class Inheritance Chapter 11 Inheritance is
- Slides: 13
Chapter 11 Class Inheritance
Chapter 11 • Inheritance is that property of objectoriented 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 • 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.
Chapter 11 Format for Declaring Derived Classes class derived class : public base class { Derived Class Member Functions Derived Class Member Data }; //END CLASS
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.
Chapter 11 • An abstract class is a base class for which objects will never be created.
Chapter 11 • A public base class allows all public members of the base class to be public in the derived class.
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.
Chapter 11 Use #ifndef When Declaring Base Classes in C++, as follows: #ifndef HEADER FILE NAME_H #define HEADER FILE NAME _H BASE CLASS DECLARATION #endif
Chapter 11 • The term polymorphic is Greek meaning “of many forms. ” • A polymorphic function is one that has the same name for different classes of the same family, but has different implementations, or behavior, for the various classes.
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.
Chapter 11 • Static binding 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.
- Chapter 11 section 2: complex patterns of inheritance
- Chapter 16 the molecular basis of inheritance
- Chapter 15 the chromosomal basis of inheritance
- Chapter 11 complex inheritance and human heredity test
- Chapter 9 patterns of inheritance
- Chapter 16 the molecular basis of inheritance
- Chapter 15 the chromosomal basis of inheritance
- The chromosomal basis of inheritance chapter 15
- Chapter 15 the chromosomal basis of inheritance
- Chapter 11 section 1 basic patterns of human inheritance
- Chapter 11 section 1 basic patterns of human inheritance
- Chapter 13-the molecular basis of inheritance
- Chapter 9 patterns of inheritance
- Chapter 15: the chromosomal basis of inheritance