Guest User

SO#20630605

a guest
Dec 17th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. function BaseFunc(x, y) {
  3.     this.X = x;
  4.     this.Y = y;
  5. }
  6. */
  7. class Base {
  8.     public X;
  9.     public Y;
  10.     function Base(x,y) {
  11.         this.X=x;
  12.         this.Y=y;
  13.     }
  14. }
  15.  
  16. /*
  17. function DerivedFunc(x, y, z) {
  18.     this.Z = z;
  19.     BaseFunc.call(this, x, y);
  20. }
  21.  
  22. DerivedFunc.prototype = new BaseFunc;
  23.  
  24. DerivedFunc.prototype.sayHello = function () {
  25.     alert("Result is: " + (this.X + this.Y + this.Z));
  26. }
  27. */
  28. class Derived : public Base {
  29.     public Z;
  30.     function Derived(x,y,z)::Base(x,y) {
  31.         this.Z=z;
  32.     }
  33.     function sayHello() {
  34.         /* alert */
  35.     }
  36. }
  37.  
  38. /*
  39. function Test() {
  40.     var d = DerivedFunc(1, 2, 3);
  41.     var b = new BaseFunc(4, 5);
  42.     d.sayHello();
  43.     b.sayHello();
  44. }
  45. */
  46. var d = new Derived(1,2,3);
  47. var b = new Base(4,5);
  48. d.sayHello();// OK
  49. b.sayHello();//Error
Advertisement
Add Comment
Please, Sign In to add comment