Mail Archives: djgpp/1999/04/13/09:57:48
hi
I have a DJGPP
but a can't compiling a litle program
a try with
gcc -lobjc main.m printer.m -o test
thanks
my program is :
main.m
// This will create a Printer object, set it's string and tell it to print
#import "Printer.h"
void main()
{
id printer = [[Printer alloc] init];
[printer addStringValue:"Hello World!"];
[printer print];
[printer free];
}
Printer.h
#import < objc/Object.h>
@interface Printer : Object
{
char buffer[100];
}
- init;
- addStringValue:(const char*)astring;
- print;
- clear;
@end
Printer.m
#import "Printer.h"
@implementation Printer
- init
{
[super init];
[self clear];
return self;
}
- addStringValue:(const char*)astring
{
strcat(buffer, astring);
return self;
}
- print
{
printf("%s\n",buffer);
[self clear];
return self;
}
- clear
{
strcpy(buffer, "");
return self;
}
@end
PD: i get it from
http://www.slip.net/~dekorte/Objective-C/Documentation/5_SampleCode/SampleCo
de1.html
- Raw text -