home *** CD-ROM | disk | FTP | other *** search
- // import the header files for all the classes
- // which we will be using: appkit.h contains
- // the header files for all the classes
-
- #import <appkit/appkit.h>
-
- // minimal Obj-C program to insert some objects
- // into a list
-
- main()
- {
- // declare the objects
- id theList, aSampleObject;
-
- // instantiate the List class using alloc
- // and initialize the list using init
- theList = [[List alloc] init];
-
- // create an object
- aSampleObject = [[Object alloc] init];
-
- // insert the objects into the list;
- [theList addObject:aSampleObject];
-
- // print how many objects are in the list
- printf("There are %d object(s) in the list\n",
- [theList count]);
-
- // demonstrate polymorphism by sending the
- // name method to theList and aSampleObject
- printf("theList is an instance of %s\n",
- [theList name]);
- printf("aSampleObject is an instance of %s\n",
- [aSampleObject name]);
-
- // exit the application
- exit(0);
- }
-