swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

address@hidden: Objective C code]


From: glen e. p. ropella
Subject: address@hidden: Objective C code]
Date: Mon, 11 Nov 1996 08:53:11 -0700

------- Start of forwarded message -------
Return-Path: <address@hidden>
Date: Mon, 11 Nov 1996 10:47:36 -0500
From: scott brown <address@hidden>
X-Mailer: Mozilla 2.02Gold (WinNT; I)
Mime-Version: 1.0
To: address@hidden
Subject: Objective C code
X-Url: http://www.santafe.edu/projects/swarm/
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Since we are also new to objective C here is the source code that 
we tried to compile using the gcc 2.7.2.1 compiler:

Maybe the code is causing the probelm?? Thanks again

                Scott

Integer.h
**********************************************************

#ifndef _Integer_h
#define _Integer_h
// test case for objective C language
#import <objc/Object.h>

@interface Integer:Object
{
int value;
}

//factory method- used to create new oabjects from class integer
+new:(int)aValue;

//initialize
- -initialize: (int) aValue;

//operations
- -increment: (int) aValue;

//display
- -print;

@end
#endif

*********************************************

Integer.m
**********************************************
//implementation of simple class integer

#import "Integer.h"
#import <stdio.h>

@implementation Integer

//factory method
+ new: (int) aValue
{
  id newInstance=[super new];
  [newInstance initialize: aValue];
  return newInstance;
}
//initialize
- -initialize: (int) aValue
{
value=aValue;
return self;
}
//operations
- -increment: (int) aValue
{
  value+=aValue;
  return self;
}
//display
- -print
{
  printf("%d\n",value);
  return self;
}

@end
******************************************************

main.m
*************************************************
//Main driver program
#import "Integer.h"
#import <stdio.h>

main()
{
  Integer *myValue=[Integer new:17];

  [myValue increment:21];
  printf("myvalue after incrementing by 21 is");
  [myValue print];
}
------- End of forwarded message -------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]