All pastes #922813 Raw Edit

GrooveMachine

public text v1 · immutable
#922813 ·published 2008-02-29 01:18 UTC
rendered paste body
#import <stdio.h>
#import <Foundation/Foundation.h>

//-------- @interface section --------

@interface Point: NSObject
{
	int  pointX;
	int  pointY;
}
-(void) print;
-(void) setPointX: (int) x;
-(void) setPointY: (int) y;

@end

//-------- @implementation section --------

@implementation Point;
-(void) print
{
	printf (" %i,%i ", pointX, pointY);
}

-(void) setPointX: (int) x
{
	pointX = x;
}

-(void) setPointY: (int) y
{
	pointY = y;
}

@end

//-------- program section --------

int main (int argc, char *argv[])
{
	Point *point1 = [[Point alloc] init];
	Point *point2 = [[Point alloc] init];

	//---- Set 1st coordinate to (2,3) ----

	[point1 setPointX: 2];
	[point1 setPointY: 3];

	//---- Set 2nd coordinate to (4,5) ----
	
	[point2 setPointX: 4];
	[point2 setPointY: 5];

	//---- Display the coordinates ----

	printf ("The first coordinate is:");
	[point1 print];
	printf ("\n");
	
	printf ("The second coordinate is:");
	[point2 print];
	printf ("\n");

	[point1 free];
	[point2 free];

	return 0;
}

// I get an error on lines 8 and 9 ('Point' redeclared as different kind of symbol
// and one on lines 11, 12 and 13 (redefinition of 'struct Point'