struct class {
int a;
int (*method)(struct class* this, int b, int c);
};
int code(struct class* this, int b, int c) {
return this->a*b+c;
}
struct class constructor(int a) {
struct class result = {a, code};
return result;
}
#define call(obj, method, ...) ((obj).method(&(obj), __VA_ARGS__))
#include <stdio.h>
int main() {
struct class obj = constructor(10);
int result = call(obj, method, 2, 3);
return 0;
}
c3RydWN0IGNsYXNzIHsKICAgIGludCBhOwogICAgaW50ICgqbWV0aG9kKShzdHJ1Y3QgY2xhc3MqIHRoaXMsIGludCBiLCBpbnQgYyk7Cn07CgppbnQgY29kZShzdHJ1Y3QgY2xhc3MqIHRoaXMsIGludCBiLCBpbnQgYykgewogICAgcmV0dXJuIHRoaXMtPmEqYitjOwp9CgpzdHJ1Y3QgY2xhc3MgY29uc3RydWN0b3IoaW50IGEpIHsKICAgIHN0cnVjdCBjbGFzcyByZXN1bHQgPSB7YSwgY29kZX07CiAgICByZXR1cm4gcmVzdWx0Owp9CgojZGVmaW5lIGNhbGwob2JqLCBtZXRob2QsIC4uLikgKChvYmopLm1ldGhvZCgmKG9iaiksIF9fVkFfQVJHU19fKSkKCiNpbmNsdWRlIDxzdGRpby5oPgppbnQgbWFpbigpIHsKICAgIHN0cnVjdCBjbGFzcyBvYmogPSBjb25zdHJ1Y3RvcigxMCk7CiAgICBpbnQgcmVzdWx0ID0gY2FsbChvYmosIG1ldGhvZCwgMiwgMyk7CiAgICBwcmludGYoIiVkXG4iLCByZXN1bHQpOwogICAgcmV0dXJuIDA7Cn0K