Adding Member Variables to Classes
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…
I am now getting a "parse error before "-" token" error. Can anyone tell me what went wrong?
"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;
}
@endI am now getting a "parse error before "-" token" error. Can anyone tell me what went wrong?
When working on the interface only the variables, not the methods, should go between the {}
So it should be more like this:
So it should be more like this:
Code:
#import <Cocoa/Cocoa.h>
@interface Cell:NSObject {
int owner;
}
- (void)setOwner;
- (int)owner;
@end
Ah, works like a charm. Thanks a lot!!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| exporting c functions and variables | NelsonMandella | 6 | 4,262 |
Apr 1, 2010 05:07 PM Last Post: NelsonMandella |
|
| Weird problem passing integer variables.. | quarus | 6 | 4,110 |
Mar 15, 2009 12:47 PM Last Post: quarus |
|
| Classes in Interface Builder | FlamingHairball | 6 | 3,499 |
Jan 9, 2008 03:01 PM Last Post: FlamingHairball |
|
| c++ array with different classes (which extend a base class) | Najdorf | 4 | 4,193 |
Aug 31, 2007 06:14 PM Last Post: Najdorf |
|
| Getting around Python's referencing of variables | Nevada | 2 | 2,876 |
Mar 10, 2007 01:07 PM Last Post: Nevada |
|

