TAILIEUCHUNG - Absolute C++ (4th Edition) part 59

Absolute C++ (4th Edition) part 59. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Inheritance Basics 587 Display Implementation for Class Employee part 2 of 2 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ssn newSsn void Employee setNetPay double newNetPay netPay newNetPay void Employee printCheck const cout nERROR printcheck FUNCTION CALLED FOR AN n UNDIFFERENTIATED EMPLOYEE. Aborting the program. n Check with the author of the program about this bug. n exit 1 SavitchEmployees You can have an undifferentiated Employee object but our reason for defining the class Employee is so that we can define derived classes for different kinds of employees. In particular the function printCheck will always have its definition changed in derived classes so that different kinds of employees can have different kinds of checks. This is reflected in the definition of the function printCheck for the class Employee Display . It makes little sense to print a check for such an undifferentiated Employee. We know nothing about this employee. Consequently we implemented the function printCheck of the class Employee so that the program stops with an error message if printCheck is called for a base class Employee object. As you will see derived classes will have enough information to redefine the function printCheck to produce meaningful employee checks. A class that is derived from the class Employee will automatically have all the member variables of the class Employee name ssn and netPay . A class that is derived from the class Employee will also have all the member functions of the class Employee such as printCheck getName setName and the other member functions listed in Display . This is usually expressed by saying that the derived class inherits the member inherits variables and member functions. The interface files with the class definitions of two derived classes of the class Employee are given in Displays HourlyEmployee and SalariedEmployee . We have placed the class Employee and the two derived classes in the same namespace. C does not .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.