Legacy:Within

Legacy:Within

From Unreal Wiki, The Unreal Engine Documentation Site

Jump to: navigation, search

The within UnrealScript keyword is used to forward class member access to another containing class. The PlayerInput class is an example of this keyword used in UT2003.

You do not need to explicitly declare within for subclasses. That is, if class A is within class B, all subclasses of A will also be within class B.

Example




 
 Foo  Object  Bar
 
 DoSomething()
{
  
  count   
}
 
 



 
 Bar  Object
 
  count
 Foo MyFoo
 
 DoSomethingElse()
{
  count  
  MyFoo()
  ( count  1 )
}

Foxpaw: How does this work WRT the instantiation of an object within another object? That is to say, how does Foo determine what instance of Bar it is "within?" It is simply by virtue of having the Foo variable in Bar? What happens if more than one instance of an object has a reference to the same Foo? What happens if you try to access properties of a Bar object from within the Foo object, but no Bar objects contain any references to Foos?

El Muerte: within is mostly a hint for the compiler (to resolve variables and functions). Foo can only be a child of a single Bar. The owner of Foo has to be of type Bar and the Bar functions and variables accessed are called on the owner.

Foxpaw: So, within gives the same effect as prepending "Bar(Owner)." to all of the properties of Bar?

Wormbo: More like "Bar(Outer).", since we are talking about non-Actor objects here. I've noticed, though, that this only applies to variables. Functions still seem to require "Outer.", but it doesn't need to be typecasted to Bar because the Within keyword already states that there can't be any other Outer class.

转载于:https://www.cnblogs.com/Zephyroal/archive/2012/02/25/2367739.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值