ITCL - 如何访问类内的关联数组成员?
如何在类本身内部访问类的关联数组成员? Itcl 是按照 C++ 建模的,在 C++ 中我们会这样写:
SomeObject.SomePublicMember = ...
How to do the same in Itcl?不提供此类数组的访问程序。我已经看到,对于通常的普通变量,可以通过使用 cget 来获得:
$this cget -PublicMemberVariableName
但是以下构造不起作用:
$this cget -AssociativeArrayName(NamedIndex)
这可能吗?
How to access associative array member of a class inside the class itself? Itcl is modeled after C++, and in C++ we would write:
SomeObject.SomePublicMember = ...
How to do the same in Itcl? Without providing accessor procedure for such an array. I've seen that for usual plain variables this can be obtained by using cget:
$this cget -PublicMemberVariableName
However the following construct doesn't work:
$this cget -AssociativeArrayName(NamedIndex)
Is this possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唉,cget 不会得到你想要的。数组元素没有一直传递到 ItclGetInstanceVar (我不知道为什么)。
您可以使用 get/set 等:
Alas, cget won't get what you want. The array element isn't passed all the way down to ItclGetInstanceVar (I'm not sure why).
You can use get/set and the like: