フィルターのクリア

Accessing object B properties outisde of object A's getter method

1 回表示 (過去 30 日間)
gareth
gareth 2012 年 4 月 3 日
I am trying to implement an object with dependent properties and therefore have a getter method to dynamically access these properties. However, I am having trouble with implementation once the properties are dependent on properties of objects outside of the particular class. EX
classdef objA
properties (Dependent)
propA
end
methods
propA = get.propA(objA)
propA = objA.propA * propB.value;
end

回答 (1 件)

Alex Taylor
Alex Taylor 2012 年 4 月 3 日
Sounds like your class objA should define a property that holds the object(s) you need to define your get operation.
classdef objA
properties (Dependent)
propA
propB
end
methods
propA = get.propA(objA)
propA = objA.propA * propB.value;
end
  1 件のコメント
gareth
gareth 2012 年 4 月 3 日
Thank you for the response. I had previously considered your suggestion however, what if propB is truly a property of some other uniquely different class. Ex: if objA.propA = tire.weight & objB.propB = door.weight. ( This is probably a bad example compared to the early given code)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by