is It possible to overload dot notation operator?

11 ビュー (過去 30 日間)
Lior
Lior 2012 年 2 月 14 日
編集済み: ibrahim abufeseifes 2013 年 10 月 11 日
Hi all, I would like to overload the dot notation of my object. for example if I have am object 'obj", I would like that obj.fun1 will do something else than from call the "fun1" method. Is it possible? Thansks, ior
  1 件のコメント
Lior
Lior 2012 年 2 月 14 日
Thanks,
This helped me a lot.

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

採用された回答

Friedrich
Friedrich 2012 年 2 月 14 日
Hi,
I think you have to overload the subsasgn function
There you see the following example:
See how MATLAB calls subsasgn for the expression:
A.field = B;
The syntax A.field = B calls A = subsasgn(A,S,B) where S.type = '.' and S.subs = 'field'.
So it can be tricky to overload it probably.
See also here:
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 2 月 14 日
Right, subsasgn() if the object appears on the left side of an assignment, subsref() otherwise.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by