what relational operator is comparing without class method overloading
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!