Audyn Curless
Audyn Curless

Reputation: 1

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-qualifier-list before 'XYPoint'

how can I fix this?

Upvotes: 0

Views: 106

Answers (2)

Sherm Pendley
Sherm Pendley

Reputation: 13612

In Circle.h, you need to declare the XYPoint class:

@class XYPoint;

Then, in Circle.m, import its full definition:

#import "XYPoint.h"

Upvotes: 3

hennes
hennes

Reputation: 9342

You need to include the appropriate header file that defines the XYPoint class.

Upvotes: 1

Related Questions