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 {
精彩评论