Thread Rating:
  • 416 Vote(s) - 2.83 Average
  • 1
  • 2
  • 3
  • 4
  • 5
フィールドはオーバーライドできない?
09-04-2013, 11:09 PM,
#2
RE: フィールドはオーバーライドできない?
クラスの振る舞いではなく、内部に保持している値をオーバーライドすると言うと、
物凄い違和感を感じるのですが…

>目的は、抽象クラスでフィールド名を定義し、子供のクラスで、そのインスタンスを定義することです。

こちらはなんとなくやりたい事が理解できるので、これを実現する方法ということでは、
こんなコードではどうでしょうか?

とりあえず、危険なuninitialized-value-for-type を使わず、継承先での初期化忘れは
警告してくれるかと思います。

Code:
{define-class public abstract A
  field public data:String
  
  {constructor public {default data:String}
      set self.data = data
  }
}

{define-class public B {inherits A}
  {constructor public {default}
    {construct-super.default "B"}
  }
}


Messages In This Thread
RE: フィールドはオーバーライドできない? - by dyoshida - 09-04-2013, 11:09 PM
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('962')