Adding Member Variables to Classes

Moderator
Posts: 623
Joined: 2007.09
Post: #1
As you all know, I have been going through BeyondCloisters FlipSquare Tutorial, and have come to a part that I don't quite understand. What does it mean to add a Member Variable to a class? The instructions are posted below.

"Open Cell.h and add the following member variable to the Cell class:

int owner; // cell owner"

and this is what I typed in…


Code:
#import <Cocoa/Cocoa.h>

int owner; // cell owner
@interface Cell:NSObject {



- (void)setOwner;
- (int)owner;

}

@end

I am now getting a "parse error before "-" token" error. Can anyone tell me what went wrong?
Quote this message in a reply
Member
Posts: 53
Joined: 2007.08
Post: #2
When working on the interface only the variables, not the methods, should go between the {}
So it should be more like this:

Code:
#import <Cocoa/Cocoa.h>


@interface Cell:NSObject {

int owner;

}

- (void)setOwner;
- (int)owner;


@end
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #3
Ah, works like a charm. Thanks a lot!!Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  exporting c functions and variables NelsonMandella 6 4,884 Apr 1, 2010 05:07 PM
Last Post: NelsonMandella
  Weird problem passing integer variables.. quarus 6 4,872 Mar 15, 2009 12:47 PM
Last Post: quarus
  Classes in Interface Builder FlamingHairball 6 3,984 Jan 9, 2008 03:01 PM
Last Post: FlamingHairball
  c++ array with different classes (which extend a base class) Najdorf 4 4,805 Aug 31, 2007 06:14 PM
Last Post: Najdorf
  Getting around Python's referencing of variables Nevada 2 3,225 Mar 10, 2007 01:07 PM
Last Post: Nevada