1

クラスのメンバー メソッド内で現在のオブジェクトを参照することは可能ですか。以下のコードをご検討ください。

itcl::class widget {
   private variable inst

   method ChildCount {} {
       return [llength [keylkeys inst children]]
   }
   method AddChild {childWidget} {
       inst children.[ChildCount] $childWidget
       # ***HOW TO GET THIS WORKING?***
       $childWidget SetParent $self
   }
}

$selfinに相当するものは何$childWidget SetParent $selfですか?

4

1 に答える 1

2

わかりました。もう少しオンラインで検索すると明らかです ->$this変数はそのトリックを行うはずです。

于 2016-06-28T10:58:55.280 に答える