what relational operator is comparing without class method overloading

조회 수: 5 (최근 30일)
Ron Lu
Ron Lu 2012년 11월 9일
Hello,
I was looking the example code for "Introduction to Object-Oriented Programming in MATLAB® Webinar": http://www.mathworks.com/matlabcentral/fileexchange/23616
In scenario "5 - Inheritance", I found I can compare like, balloon{1} > balloon{2}; ans=0 or balloon{2} > balloon{3}; ans = 1, without overloading the conditional operators. Arithmetic operatros will give errors without overloading which makes sense.
My question is what MATLAB is comparing for those objects, their cell array index? or inhreitance order? or some property value?
So far the retunred result is confusing. For example, balloon{1} and balloon{2} are the target class, balloon{3} is a subclass of target, if I add a balloon{5} which is also target class as balloon{1} and balloon{2}, it shows balloon{5} > balloon{2}; ans = 0, and balloon{5} > balloon{4}; ans = 1.
I knwo metaclass instance can use greater than or less than to figure out subclass relationship. But what are they doing in above situations?
Thanks

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by