2011-09-16 12 views
5

बेस क्लास में एक फ़ंक्शन f है। व्युत्पन्न वर्ग फ़ंक्शन f को ओवरराइट करता है। मैं व्युत्पन्न वर्ग के किसी ऑब्जेक्ट के लिए बेस क्लास 'एफ को कॉल करना चाहता हूं। मैं यह कैसे कर सकता हूँ?MATLAB में बेस फ़ंक्शन कॉल करने के लिए फोर्स व्युत्पन्न कक्षा?

यहां कोड नमूना है।

classdef base 

     methods (Access = public) 
      function this = f(this) 
       disp('at base::f'); 
      end 

     end 
    end 

    classdef derived < base 

     methods (Access = public) 
      function this = f(this) 
       % HERE I WANT TO CALL base::f 
       [email protected](); % this is an error 

       disp('at derived::f'); 
      end 

     end 
    end 

d = derived(); 
d.f(); 
% here the result should be 
% at base::f 
% at derived::f 

उत्तर

8

[email protected](); 

के बजाय

यह

[email protected](this) 
+0

@Vahagn है: यह Disp होगा 'व्युत्पन्न :: f' पर, के बाद से उस वक्तव्य च @ आधार के लिए कॉल के बाद मार डाला जाता है। हालांकि, मैं अनंत लूप को समझ नहीं पा रहा हूं। – Jonas

+2

@ वाहगन: यहां दस्तावेज़ में लिंक दिया गया है: http://www.mathworks.com/help/techdoc/matlab_oop/bsa1q42.html – Jonas

संबंधित मुद्दे