Chapter 14 ABSOLUTE C++ Inheritance WALTER SAVITCH SECOND EDITION PEARSON Copyright2006 Pearson Addison-Wesley All rights reserved
Chapter 14 Inheritance
Learning Objectives ◆Inheritance Basics Derived classes,with constructors protected:qualifier Redefining member functions Non-inherited functions Programming with Inheritance Assignment operators and copy constructors Destructors in derived classes Multiple inheritance Copyright 2006 Pearson Addison-Wesley.All rights reserved. 14-2
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 14-2 Learning Objectives ¨ Inheritance Basics ¨ Derived classes, with constructors ¨ protected: qualifier ¨ Redefining member functions ¨ Non-inherited functions ¨ Programming with Inheritance ¨ Assignment operators and copy constructors ¨ Destructors in derived classes ¨ Multiple inheritance
Introduction to Inheritance Object-oriented programming Powerful programming technique Provides abstraction dimension called inheritance General form of class is defined Specialized versions then inherit properties of general class And add to it/modify it's functionality for it's appropriate use Copyright6 Pearson Addison-Wesley.All rights reserved. 14-3
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 14-3 Introduction to Inheritance ¨ Object-oriented programming ¨ Powerful programming technique ¨ Provides abstraction dimension called inheritance ¨ General form of class is defined ¨ Specialized versions then inherit properties of general class ¨ And add to it/modify it’s functionality for it’s appropriate use
Inheritance Basics New class inherited from another class ◆Base class "General"class from which others derive ◆Derived class ◆New class Automatically has base class's: ◆Member variables ◆Member functions Can then add additional member functions and variables Copyright 2006 Pearson Addison-Wesley.All rights reserved. 14-4
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 14-4 Inheritance Basics ¨ New class inherited from another class ¨ Base class ¨ "General" class from which others derive ¨ Derived class ¨ New class ¨ Automatically has base class’s: ¨ Member variables ¨ Member functions ¨ Can then add additional member functions and variables
Derived Classes ◆ Consider example: Class of "Employees" ◆Composed of: ◆Salaried employees ◆Hourly employees Each is "subset"of employees Another might be those paid fixed wage each month or week Copyright 2006 Pearson Addison-Wesley.All rights reserved. 14-5
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 14-5 Derived Classes ¨ Consider example: Class of "Employees" ¨ Composed of: ¨ Salaried employees ¨ Hourly employees ¨ Each is "subset" of employees ¨ Another might be those paid fixed wage each month or week