0

In C++, you can easily get a function pointer to the method of a class:

doIt = &MyClass::DoIt; // get a function pointer on method DoIt in class MyClass
...
(*this.*doIt)(x, y, z); // Call the function on an instance on MyClass (this for example)
...

But how can I do this in Matlab? I tried something with doIt = MyClass.DoIt, but that does not work.

(I will need this for a message passing scheme: The function pointer will be handed to various instances of the class in a message in order to call the respective function on the respective instance.)

Michael
  • 7,407
  • 8
  • 41
  • 84
  • Yes, that is true - but not very obvious. Should I delete my question in that case? – Michael Jan 11 '15 at 23:11
  • 1
    It depends. It's not necessarily a bad thing to have duplicate questions on stackoverflow. Someone might be looking for a phrasing of this question similar to yours and this way will find the answer. It should nonetheless encourage you to do more in-depth search around stackoverflow before your next question, as it is highly likely someone already asked something similar most of the time. – knedlsepp Jan 11 '15 at 23:58
  • 1
    @knedlsepp - Yup, that's why I marked is as duplicate. That's one of the reasons why StackOverflow has that duplicate option! – rayryeng Jan 12 '15 at 01:08

0 Answers0