61 lines
975 B
C
61 lines
975 B
C
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
class someClass{
|
||
|
|
|
||
|
|
char * value = "someValue";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class callback{
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
|
||
|
|
this->testCallbacks();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void callCallback( void ( * function )( struct someClass * caller, int ) , int number, struct someClass * caller ) {
|
||
|
|
|
||
|
|
function( caller, number );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void printTest( struct someClass * caller, int a ) {
|
||
|
|
|
||
|
|
printf("print test: %i %s .\n\n\n\n", a, caller->value);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void anotherPrintTest( struct someClass * caller, int a ) {
|
||
|
|
|
||
|
|
//struct user * someUser = someObject;
|
||
|
|
|
||
|
|
printf("another print test: %i %s .\n\n\n\n", a, caller->value);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void testCallbacks() {
|
||
|
|
|
||
|
|
someClass * instance = new someClass();
|
||
|
|
|
||
|
|
this->callCallback( this->printTest, 1234, instance );
|
||
|
|
|
||
|
|
this->callCallback( this->printTest, 5678, instance );
|
||
|
|
|
||
|
|
this->callCallback( this->printTest, 910, instance );
|
||
|
|
|
||
|
|
this->callCallback( this->anotherPrintTest, 910, instance );
|
||
|
|
|
||
|
|
this->callCallback( this->anotherPrintTest, 910, instance );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|