is It possible to overload dot notation operator?

10 vues (au cours des 30 derniers jours)
Lior
Lior le 14 Fév 2012
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 commentaire
Lior
Lior le 14 Fév 2012
Thanks,
This helped me a lot.

Connectez-vous pour commenter.

Réponse acceptée

Friedrich
Friedrich le 14 Fév 2012
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 commentaire
Walter Roberson
Walter Roberson le 14 Fév 2012
Right, subsasgn() if the object appears on the left side of an assignment, subsref() otherwise.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by