tailieunhanh - Chapter 14 Inheritance

Derived classes from Employee class, Automatically have all member variables. Automatically have all member functions Derived class said to "inherit" members from base class | 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 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 Derived Classes Consider example: Class of "Employees" Composed of: Salaried employees Hourly employees Each is "subset" of employees Another might be . | 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 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 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 Derived Classes Don’t "need" type of generic "employee" Since no one’s just an "employee" General concept of employee helpful! All have names All have social security numbers Associated functions for these "basics" are same among all employees So "general" class can contain all these "things" about employees Employee Class Many members of "employee" class apply to all types of employees Accessor functions Mutator functions Most data items: SSN Name Pay We won’t have "objects" of this class, however Employee Class Consider printCheck() function: Will always be "redefined" in derived classes So different employee types can have different checks Makes no sense really for "undifferentiated" employee So function printCheck() in Employee class says just that Error message stating "printCheck called for undifferentiated employee!! Aborting " Deriving from Employee Class Derived classes from Employee class: Automatically have all member variables .

TÀI LIỆU MỚI ĐĂNG
8    170    0    19-04-2024
22    117    0    19-04-2024
40    96    0    19-04-2024
185    96    0    19-04-2024
11    108    0    19-04-2024
5    97    0    19-04-2024
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.