Advertisement
snake5

sgs inheritance, latest

Feb 23rd, 2016
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1.  
  2.  
  3. global base = { static = 1 };
  4.  
  5. function base.create()
  6. {
  7.     // instance
  8.     return class({ local = 2 }, base);
  9. }
  10.  
  11. function base.method( a )
  12. {
  13.     println({ local = this.local, a });
  14. }
  15.  
  16.  
  17. global extended = class({}, base );
  18.  
  19. function extended.create()
  20. {
  21.     return class({ local = 5 }, extended );
  22. }
  23.  
  24. function extended.method( a )
  25. {
  26.     println( "extended" );
  27.     this!base.method( a );
  28. }
  29.  
  30.  
  31. test1 = base.create();
  32. test1.method( "yay" );
  33. test2 = extended.create();
  34. test2.method( "ext" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement