Path: news.mathworks.com!not-for-mail
From: "Sven" <sven.holcombe@gmail.deleteme.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Using subclass 'get' function to access inherited superclass property
Date: Thu, 12 Nov 2009 18:37:02 +0000 (UTC)
Organization: University of Michigan
Lines: 44
Message-ID: <hdhkke$m7a$1@fred.mathworks.com>
References: <hd4h94$g23$1@fred.mathworks.com>
Reply-To: "Sven" <sven.holcombe@gmail.deleteme.com>
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 1258051022 22762 172.30.248.35 (12 Nov 2009 18:37:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 12 Nov 2009 18:37:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1326470
Xref: news.mathworks.com comp.soft-sys.matlab:584663


I have the exact same conundrum. If anyone knows an answer (even if that answer is "MATLAB can't do this in the current version"), please post it here.

When I add a get.supclass_property(this) method to my subclass, MATLAB tells me:
"Cannot specify a get function for property 'supclass_property' in class 'subclass', because that property is not defined by that class.

When I go ahead and *add* supclass_property as a property of my subclass, MATLAB tells me:
"Cannot define property 'supclass_property' in class 'subclass' because the property has already been defined in the super-class 'supclass'.

The only way I can get around it at the moment is to *remove* the supclass_property from the superclass altogether, which, to me seems like rather poor design.

Thanks,
Sven.

"Janice " <janice_chou@yahoo.com> wrote in message <hd4h94$g23$1@fred.mathworks.com>...
> 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