Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Pointer to class member function?

From   Richard Foltyn <>
Subject   st: Pointer to class member function?
Date   Fri, 3 May 2013 15:36:56 +0200

Dear Listers,

I need to create a pointer to a class member function, but cannot
figure out how to do that. The usual way of using &func() does not
work, and neither do other "obvious" alternatives such as &this.func()
or &(this.func)().

Here is a demo code that does nothing useful to illustrate what I am
trying to achieve:


class testClass {
        void run1()
        void run2()
        real scalar func()

real scalar testClass::func(real scalar arg) {

void testClass::run2(pointer(real scalar function) scalar f, ///
    real scalar arg) {

void testClass::run1() {
    this.run2(&func(), 1)

foo = testClass()


Running this I get the error message:

: foo.run1()
       testClass::run1():  3499  func() not found [3]
                 <istmt>:     -  function returned error [1]

Thanks for your help!
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index