TAILIEUCHUNG - CRC.Press A Guide to MATLAB Object Oriented Programming May.2007 Episode 1 Part 10

Tham khảo tài liệu ' a guide to matlab object oriented programming episode 1 part 10', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 154 A Guide to MATLAB Object-Oriented Programming Inheritance supports code reuse in several ways. In the hierarchy a child can rely on functions located in the parent-class directory. Many different child classes from the same parent can easily reuse the same function. In client code a child can temporarily masquerade as a parent because the child s interface contains the same public members. Any client code that worked with a parent object will still work with a child. Inheritance occurs without the parent even knowing that the child exists. This is important because coupling in the hierarchy only goes one way. Inheritance couples the child to the parent but not the other way around. Changes in the parent ripple down the hierarchy to all the children but changes to children are not reflected in the parent. Achieving the promise of one-way-only coupling is one reason we spent so much time nailing shut every possible hole in encapsulation. SIMPLE INHERITANCE Since this is the first chapter on inheritance we are going to walk before we run. We will use cShape as the parent class for cStar and cDiamond but the only functional difference will occur in the constructor. A simplified diagram of the inheritance relationship is shown in Figure . We could further simplify inheritance by only supporting scalar objects. In the simple case with scalar objects the implementation is too easy. That example would be almost worthless compared to an example that includes full array support. As with encapsulation our goal with inheritance is to develop a robust example that can be used as a reference design for other classes. To get to that point we need to add a few improvements to the group of eight. These modifications are only necessary for child classes however there is no harm in adding inheritance support to every class. If the hierarchy needs to evolve the basic scaffolding will already be in place. Constructor Every class needs a constructor it is an .

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.