Using an object as an instance variable in a basic Objective C program, I get an "expected specifier-qualifier-list" error
I am writing a simple program that uses an object *center from an XYPoint class as an instance variable.
@interface Circle : NSObject {
int radius;
XYPoint *center;
}
however, I get this error message when compiling the code:
error: expected specifier-quali开发者_运维知识库fier-list before 'XYPoint'
how can I fix this?
In Circle.h, you need to declare the XYPoint class:
@class XYPoint;
Then, in Circle.m, import its full definition:
#import "XYPoint.h"
You need to include the appropriate header file that defines the XYPoint
class.
精彩评论