Initial commit
This commit is contained in:
60
application/source/callbacks.c
Normal file
60
application/source/callbacks.c
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user