#include <stdlib.h>
#include <stdio.h>
/** Responseクラス開始 **/
//メンバ
typedef struct {
int no;
int (*getNo)();
void (*setNo)();
} Response;
// プロトタイプ宣言
Response* Response_new( int no);
void Response_init(Response* this,int no);
void Response_setNo(Response* this,int no);
int Response_getNo(Response* this);
//メソッド
Response* Response_new(int no) {
Response
* this
= malloc(sizeof(Response
)); /* 自分自身の生成 */
//メソッドを構造体に入れる
this->setNo=Response_setNo;
this->getNo=Response_getNo;
Response_init(this,no);//コンストラクタを呼ぶ
return this;
}
void Response_delete(Response* this){
}
void Response_init(Response* this,int no){
this->no=no;
}
void Response_setNo(Response* this,int no){
this->no=no;
}
int Response_getNo(Response* this){
return this->no;
}
/** Responseクラス終了**/
int main (){
Response* res=Response_new(1);
(*res->setNo)(res,10);
printf("%d\n",(*res
->getNo
)(res
)); Response_delete(res);
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RkaW8uaD4KCi8qKiBSZXNwb25zZeOCr+ODqeOCuemWi+WniyAqKi8KLy/jg6Hjg7Pjg5AKdHlwZWRlZiBzdHJ1Y3QgewoJaW50IG5vOwoJaW50ICgqZ2V0Tm8pKCk7Cgl2b2lkICgqc2V0Tm8pKCk7Cn0gUmVzcG9uc2U7CgovLyDjg5fjg63jg4jjgr/jgqTjg5flrqPoqIAgClJlc3BvbnNlKiAgUmVzcG9uc2VfbmV3KCBpbnQgbm8pOwp2b2lkIFJlc3BvbnNlX2luaXQoUmVzcG9uc2UqIHRoaXMsaW50IG5vKTsKdm9pZCBSZXNwb25zZV9zZXRObyhSZXNwb25zZSogdGhpcyxpbnQgbm8pOwppbnQgUmVzcG9uc2VfZ2V0Tm8oUmVzcG9uc2UqIHRoaXMpOwoKLy/jg6Hjgr3jg4Pjg4kKUmVzcG9uc2UqICBSZXNwb25zZV9uZXcoaW50IG5vKSB7CglSZXNwb25zZSogIHRoaXMgPSBtYWxsb2Moc2l6ZW9mKFJlc3BvbnNlKSk7ICAvKiDoh6rliIbo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