TAILIEUCHUNG - C++ Weekend Crash Course phần 7

C + + là thực tế duy nhất cho phép các lập trình để thực hiện các hoạt động này bản thân mình. ¼ hoạt động của con trỏ trên mảng ký tự được cung cấp các Nhà điều hành chuyển nhượng giống như các nhà xây dựng bản sao. Khi sử dụng, hai trông gần như giống hệt nhau | Session 21 Inheritance 303 Class Factoring To make sense out of our surroundings humans build extensive taxonomies. Fido is a special case of dog which is a special case of canine which is a special case of mammal and so it goes. This shapes our understanding of the world. To use another example a student is a special type of person. Having said this I already know a lot of things about students. I know they have social security numbers they watch too much TV they drive a car too fast and they don t exercise enough. I know all these things because these are properties of all people. In C we call this inheritance. We say that the class Student inherits from the class Person. We say also that Person is a base class of Student and Student is a subclass of Person. Finally we say that a Student IS_A Person I use all caps as my way of expressing this unique relationship . C shares this terminology with other object-oriented languages. Notice that although Student IS_A Person the reverse is not true. A Person is not a Student. A statement like this always refers to the general case. It could be that a particular Person is in fact a Student. A lot of people who are members of class Person are not members of class Student. This is because the class Student has properties it does not share with class Person. For example Student has a grade point average but Person does not. The inheritance property is transitive however. For example if I define a new class GraduateStudent as a subclass of Student GraduateStudent must also be Person. It has to be that way if a GraduateStudent IS_A Student and a Student IS_A Person then a GraduateStudent IS_A Person. 20 Min. To Go Implementing Inheritance in C To demonstrate how to express inheritance in C let s return to the GraduateStudent example and fill it out with a few example members GSInherit - demonstrate how the graduate student class can inherit the properties of a Student include include include Part .

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.