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

채택된 답변

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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by