Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Using subclass 'get' function to access inherited superclass property
Date: Sat, 7 Nov 2009 19:20:04 +0000 (UTC)
Organization: Princeton University
Lines: 30
Message-ID: <hd4h94$g23$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257621604 16451 172.30.248.35 (7 Nov 2009 19:20:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 7 Nov 2009 19:20:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1598644
Xref: news.mathworks.com comp.soft-sys.matlab:583256


Hi all,

I have read several posts about the problems with overloading a superclass 'set'/'get' function, but I'm interested in simply writing a subclass 'get' function that is able to return an inherited superclass property. It seems that the 'get' function is blind to the superclass properties, despite the fact that one could simply access this property by using dot notation with the subclass object (if the property is public?) elsewhere in the code. The code I'm using is below:

classdef ExptBasic < handle

     properties (GetAccess = 'public', SetAccess = 'protected')
          logfile_name = '';
     end

     methods
          function value = get.logfile_name(Expt)
               value = Expt.logfile_name;
          end
     end

end

classdef TrialBasic < ExptBasic
     methods
          function get.logfile_name(Trial)
               value = get.logfile_name@ExptBasic(Trial);
          end
     end
end

Am I going about this the wrong way? I tried extending the superclass 'get.logfile_name' method in the subclass TrialBasic.

Thanks in advance for the help,
Janice