开发者

Interesting loop? How can a base class include a child class as a member?

How can a base class include a child开发者_如何转开发 class as a member? For example:

@interface Magic : NSObject {
@private
       NSString* name;
       int power;
       int manaCost;
       SpecialKindOfMagic* thisMuch;
}
@end

@interface SpecialKindOfMagic : Magic {
@private
       int thisMuchSpecial;
}
@end


Use a forward declaration before the declaration of the Magic class:

@class SpecialKindOfMagic;

@interface Magic ...

Also, it's very unusual to declare a class that doesn't descend from NSObject, so you probably meant to write:

@interface Magic : NSObject {
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜