c 2b 2b callback member function

Solutions on MaxInterview for c 2b 2b callback member function by the best coders in the world

showing results for - "c 2b 2b callback member function"
Alma
11 Sep 2017
1class Foo {
2	int (*func)(int);
3  
4public:
5  	void setCallback( int (*cFunc)(int) ) {
6      func = cFunc;
7    }
8  
9  	void set() {
10    	setCallback(callback);	// Set callback function to be called later
11    }
12  
13    void use() {
14      	func(5);	// Call the previously set callback function
15    }
16          
17  	// Note the 'static'
18    static int callback(int param) {
19      	return 1;
20    }
21};