[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: override display() for class
From: |
CdeMills |
Subject: |
Re: override display() for class |
Date: |
Fri, 10 Dec 2010 01:18:38 -0800 (PST) |
display receives as input the VALUE of an object, it is up to this function
to suitably produce a text with the fields of the object. To determine the
NAME of the argument passed to the function, use the "inputname" function?
So your overloaded function should be
function text = display(myclass)
text = sprintf('%s value is %d', inputname(1), myclass.val)
endfunction
Now, overloading means having the ability to mimic some fundamental
function, applied to a class you did define. In the name of the "least
surprise effect", you should try to stay as close as possible to the
fundamental function behaviour.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/override-display-for-class-tp3081116p3081620.html
Sent from the Octave - General mailing list archive at Nabble.com.
- override display() for class, Steve White, 2010/12/09
- Re: override display() for class,
CdeMills <=
- RE: override display() for class, Steve White, 2010/12/10
- RE: override display() for class, CdeMills, 2010/12/10
- RE: override display() for class, Steve White, 2010/12/11
- Re: override display() for class, Jaroslav Hajek, 2010/12/12
- RE: override display() for class, Steve White, 2010/12/12
- Re: override display() for class, CdeMills, 2010/12/13
- Re: override display() for class, Ben Abbott, 2010/12/13
- Re: override display() for class, John W. Eaton, 2010/12/13
- Re: override display() for class, bpabbott, 2010/12/13
- Re: override display() for class, John W. Eaton, 2010/12/13