Guest User

Untitled

a guest
Sep 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include "MyClass.h"
  2.  
  3. // ここにプロトタイプ書くことで見えなくする。
  4. void MyClass_method(MyClass* this, int a);
  5. int MyClass_func(MyClass* this, int arg);
  6.  
  7. void MyClass_constructor(MyClass* this) {
  8. // スーパークラスのコンストラクト
  9. MySuper_constructor((MySuper*)this);
  10. // MyClassのコンストラクト
  11. this->mem = 10;
  12. this->method = MyClass_method;
  13. this->func = MyClass_func;
  14. }
  15.  
  16. void MyClass_method(MyClass* this, int a){
  17. this->mem += a;
  18. return;
  19. }
  20.  
  21. // オーバーライドする
  22. int MyClass_func(MyClass* this, int arg) {
  23. // スーパークラスの処理
  24. int res = ((MySuper*)this)->func((MySuper*)this, arg);
  25. return res * res;
  26. }
Add Comment
Please, Sign In to add comment