Đang chuẩn bị liên kết để tải về tài liệu:
A Complete Guide to Programming in C++ part 53

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

A Complete Guide to Programming in C++ part 53. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | chapter 23 Inheritance This chapter describes how derived classes can be constructed from existing classes by inheritance. Besides defining derived classes we will also discuss how members are redefined how objects are constructed and destroyed and how access control to base classes can be realized. 499 500 CHAPTER 23 INHERITANCE CONCEPT OF INHERITANCE Is relation Car Properties and capacities of class Car PassCar Truck Properties and capacities of class Car Properties and capacities of class Car Additional properties and capacities of class PassCar Additional properties and capacities of class Truck CONCEPT OF INHERITANCE 501 Base Classes and Derived Classes Inheritance allows new classes to be constructed on the basis of existing classes. The new derived class inherits the data and methods of the so-called base class. But you can add more characteristics and functionality to the new class. A fleet management program used by a car hire company needs to handle all kinds of vehicles automobiles motorcycles trucks and so on. All of these vehicles have an identification number that indicates the vehicle the manufacturer and the vehicle status such as hired repair shop and so on. Additionally operations such as modify status are required for the class. To differentiate between vehicle types various classes are derived from the base class Car such as PassCar which is used to represent passenger-carrying vehicles. This class has additional attributes such as the number of seats type sunroof yes no and various additional operations. Is Relationship An object of the PassCar type is a special object of the Car class. A passenger vehicle is a special kind of car. In cases like this we can say that the derived class establishes an is relationship to the base class. We distinguish between this close relationship and a so-called has relationship. As already mentioned a has relationship occurs between two classes when an member of one class has another class type. An Account .

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.