R. Barrett
0
Q:

c++ callback member function

class Foo {
	int (*func)(int);
  
public:
  	void setCallback( int (*cFunc)(int) ) {
      func = cFunc;
    }
  
  	void set() {
    	setCallback(callback);	// Set callback function to be called later
    }
  
    void use() {
      	func(5);	// Call the previously set callback function
    }
          
  	// Note the 'static'
    static int callback(int param) {
      	return 1;
    }
};
1

New to Communities?

Join the community