Dòng 61 và chức năng hướng đối tượng bình thường lựa chọn chuyển tiếp yêu cầu nhận được để phụ huynh. Nếu dòng 61 thành công trả về một giá trị, dòng 62 bộ đúng sự thật. Dòng 63 sau đó xảy ra của vòng lặp parent_name. Sau khi vòng lặp nhận được một giá trị từ một phụ huynh, không có lý do để yêu cầu khác. | Constructing Simple Hierarchies with Inheritance 165 Line 61 and normal object-oriented function selection forward the get request to the parent. If line 61 successfully returns a value line 62 sets found to true. Line 63 then breaks out of the parent_name loop. Once the loop receives a value from one parent there is no reason to ask another. If line 61 is not successful the parent at the top of the hierarchy will throw a MATLAB nonExistentField error. Lines 62-63 are skipped and the error is caught by line 64. Line 65 makes sure found is set to false line 66 loads the error into err and line 67 selects a case based on the error identifier. If the identifier is MATLAB nonExistentField program control jumps back to the beginning of the parent_name loop. Maybe the value will be found in the next parent. Any other error is a lot more serious and is rethrown by line 71. If the parent_name loop completes without finding a value found will be false and standard error processing will occur. The parent-forwarding section in lines 43-76 is general and can be included in every class get. This is even true for parentless base classes because parent_list returns an empty cellstr. The standard implementation of get will always include a parent-forwarding block. Child Class set After inserting a parent-forwarding section inside get we are in an excellent position to insert the same functionality into set. The basic idea is the same but the direction is different. With set we are trying to assign not access parent values. Assignment is a little harder because we need to slice the object forward the request and glue the child portion back to the parent. Code to implement get for both cStar and cDiamond is shown in Code Listing 69. The parentforwarding block in this listing is general and can be added to every version of set. Code Listing 69 Implementing Parent Forwarding in cStar s I function varargout set this index varargin 2 3 one two arguments display info and .