tailieunhanh - A Guide to MATLAB Object-Oriented Programming phần 10

Nhấp vào nút Lưu Thay đổi cam kết những thay đổi và hiển thị các mẫu thử nghiệm chức năng trong định dạng WYSIWYG. Trong thế hệ tập tin, Class Wizard viết cùng một mẫu thử nghiệm chức năng vào chức năng tư nhân và sau các mẫu thử nghiệm với ý kiến tiêu đề. | Pass-by-Reference Emulation 317 Pass-by-Reference Behavior in the Helper Earlier versions of cShape did not include a public variable named View. The example files in this chapter s directory include View as an addition. From previous experience we know we can add a new public variable without introducing unexpected side effects. In the Class Wizard Public Variables . dialog add a new public variable named View and enter helper in both the Accessor Expression and Mutator Expression fields. No further changes are required because the value of View relies on private variables that already exist. Save the change and rebuild the files. Class Wizard writes an initial version of into @cShape private . The initial version must always be tailored to match the desired behavior. The tailored version is shown in Code Listing 131. Code Listing 131 Enabling a Helper with Call-by-Reference Behavior 1 function do_sub_indexing do_assignin this varargout . 2 View_helper which this index varargin 3 4 switch which 5 case get ACCESSOR 6 input index contains any additional indexing as a substruct 7 input varargin empty for accessor 8 do_sub_indexing true tells whether to index deeper 9 do_assignin true call-by-reference behavior 10 varargout cell 1 nargout-3 3 known vars plus varargout 11 12 before the toggle means standard load after-toggle values 13 developer_sieve cellfun isempty 14 toggle the display function remember false means standard 15 this developer_sieve .mDisplayFunc deal developer_view 16 this developer_sieve .mDisplayFunc deal 17 18 fill varargout with the requested data 19 varargout num2cell developer_sieve 20 21 case set MUTATOR 22 input index contains any additional indexing as a substruct 23 input varargin contains values to be assigned into the object 24 do_sub_indexing false mutator _must_ do deep indexing 318 A Guide to MATLAB Object-Oriented Programming 25 do_assignin false leave false until you read book section 3 .

TỪ KHÓA LIÊN QUAN
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.