home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / objectiv / 698 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.8 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!ohstpy!miavx1!miamiu!toznal
  2. Newsgroups: comp.lang.objective-c
  3. Subject: Re: problem with similar instance method names
  4. Message-ID: <92356.154409TOZNAL@MIAMIU.BITNET>
  5. From: tuncay <TOZNAL@MIAMIU.BITNET>
  6. Date: Monday, 21 Dec 1992 15:44:09 EST
  7. References: <1992Dec18.183133.6855@ennews.eas.asu.edu>
  8. Distribution: comp.lang.objective-c
  9. Organization: Miami University - Academic Computer Service
  10. Lines: 63
  11.  
  12. hi,
  13. In article <1992Dec18.183133.6855@ennews.eas.asu.edu>,
  14. raothall@iienext1.cim.eas.asu.edu (Karthic V. Rao-Thallikar) says:
  15. >
  16.  
  17. I ran into the same problem with compiling the same program on the NeXT
  18. platform.  My advisor solved the problem by:first including the header files of
  19. the classes istead of .m files, then, compiling the .m files all together.
  20.  
  21. cc -ObjC Integer.m Float.m Fraction.m theMain.m
  22. rm
  23. >To all Objective-C Guru's:
  24. >I am starting to write code in ObjecC. I am familiar with 'C'.
  25. >My understanding of OOP is that if there are two similar classes eg
  26. >Integer and Float the user can have the facility of using similarly named
  27. >instance methods to operate on these classes. Just to try this out i coded
  28. >the following lines. But the compiler reports errors for the 'initialize'
  29. >and 'incrementBy' methods, and used the method defined for the Integer
  30. >Class.
  31. >Please do reply the correct procedure.
  32. >I am using NeXt 3.0, and NeXt's ObjectiveC version that comes with the 3.0
  33. >version.
  34. >Thank you all in advance.
  35. >Following is the code.
  36. >They are in different file but I have 'cat' them for convinience.
  37. >The error from the compiler is appended at the end for reference.
  38. >
  39. >//Test program  for late bindind
  40. >#import "Integer.m"
  41. >#import "Float.m"
  42.  
  43. Here, import the header files: Integer.h, Float.h and Fraction.h
  44.  
  45. >#import "Fraction.m"
  46. >#import <stdio.h>
  47. >
  48. >errors are:
  49.  
  50. >> cc test.m
  51.  
  52. you have to use -ObjC option when you compile Objective C code in the NeXT
  53. platform, as far as I know.  Use the following command:
  54.  
  55.     cc -ObjC Integer.m Float.m Fraction.m test.m -o test
  56.  
  57. >Float.m: In method `new:'
  58. >In file included from test.m:4:
  59. >Float.m:8: warning: multiple declarations for method `initialize:'
  60. >Integer.h:11: using `-initialize:(int)anInt'
  61. >Float.h:10: also found `-initialize:(float)aValue'
  62. >Float.m: In method `incrementBy:'
  63. >Float.m:20: conflicting types for `-incrementBy:(float)aValue'
  64. >Float.h:12: previous declaration of `-incrementBy:(int)aValue'
  65. >test.m: In function `main':
  66. >test.m:46: warning: multiple declarations for method `incrementBy:'
  67. >Integer.h:13: using `-incrementBy:(int)aValue'
  68. >Float.m:20: also found `-incrementBy:(float)aValue'
  69. >>
  70. The above two changes should fix the problem.  I like PINSON/WIENER'S book
  71. a lot despite the fact that I could not work some of their code on
  72. the machine that I use. It is a NeXT, too.
  73.  
  74. Have fun.
  75.