home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5941 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.7 KB  |  65 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!oceania!jim
  3. From: jim (Jim Mackraz)
  4. Subject: Re: Multiple init: functions defined
  5. Message-ID: <Btz6sL.8qC@oceania.com>
  6. Sender: jim@oceania.com (Jim Mackraz)
  7. Reply-To: jim@oceania.com
  8. Organization: Oceania Health Care Systems
  9. References: <3575@richsun.cpg.trs.reuter.com>
  10. Date: Thu, 3 Sep 1992 00:02:43 GMT
  11. Lines: 52
  12.  
  13. Jack Gidding writes
  14. > Hmmmm..... this is really strange and very undesired behavior from  
  15. Objective-C.
  16. > When I include the header files from two different classes into a third  
  17. class,  
  18. > and each of the included classes have a single init: method defined, I get  
  19. > messages similar to the following:
  20. > main2.m:18: warning: multiple declarations for method `init:'
  21. > /Clib/RP.h:32: using `-init:(int )pSize'
  22. > /Clib/RS.h:31: also found `-init:(OBJPTR )s'
  23. > Why is this happening??? Sometimes it tells me that it resolved which init to  
  24. > use, sometimes not, and sometimes it resolves it to the wrong init:.
  25. > The code that has the init method is sililar in form to:
  26. >     #import <RP.h>    // Both RP and RS have and init: method
  27. >     #import <RS.h>
  28. >     id x;
  29. >     x = [[RP alloc] init:(int) 5];
  30. > id is totally dynamic, and thus it really does not know which init to use....
  31. > So, why is it telling me that it is using one method or another...shouldn't  
  32. > this be left up until run-time? 
  33. > Am I doing something wrong to cause this?
  34.  
  35. Yeah, you're "type overloading" the method "init:".  Don't do that.
  36. Make one of the "-initInt: (int) intVal" and the other one
  37.  "-initObj: (OBJPTR) obj"
  38.  
  39. ... or something like that.
  40.  
  41.  
  42. > Thanks,
  43. > Jack Gidding
  44. > jack@richsun.cpg.trs.reuter.com
  45. -- 
  46. Jim Mackraz
  47. jim@oceania.com
  48.