29 lines
441 B
C
29 lines
441 B
C
#include <stdio.h>
|
|
#include "handle.h"
|
|
|
|
struct Meaning {
|
|
int a;
|
|
int b;
|
|
};
|
|
|
|
handle(Meaning) {
|
|
if(state == HANDLE_CREAT) {
|
|
this->a = *(int*) data;
|
|
this->b = 2;
|
|
} else {
|
|
// Destructor
|
|
printf("%d\n", this->a + this->b);
|
|
}
|
|
}
|
|
|
|
// Now you can use a handle in your local scopes
|
|
// Should print 42:
|
|
int main() {
|
|
int initializer = 40;
|
|
creat(Meaning, d, &initializer);
|
|
initializer = 20;
|
|
creat(Meaning, d2, &initializer);
|
|
|
|
return 0;
|
|
}
|