home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: sparky!uunet!oceania!jim
- From: jim (Jim Mackraz)
- Subject: Re: Multiple init: functions defined
- Message-ID: <Btz6sL.8qC@oceania.com>
- Sender: jim@oceania.com (Jim Mackraz)
- Reply-To: jim@oceania.com
- Organization: Oceania Health Care Systems
- References: <3575@richsun.cpg.trs.reuter.com>
- Date: Thu, 3 Sep 1992 00:02:43 GMT
- Lines: 52
-
- Jack Gidding writes
- >
- > Hmmmm..... this is really strange and very undesired behavior from
- Objective-C.
- >
- > When I include the header files from two different classes into a third
- class,
- > and each of the included classes have a single init: method defined, I get
- > messages similar to the following:
- >
- >
- > main2.m:18: warning: multiple declarations for method `init:'
- > /Clib/RP.h:32: using `-init:(int )pSize'
- > /Clib/RS.h:31: also found `-init:(OBJPTR )s'
- >
- >
- > Why is this happening??? Sometimes it tells me that it resolved which init to
- > use, sometimes not, and sometimes it resolves it to the wrong init:.
- >
- >
- > The code that has the init method is sililar in form to:
- >
- > #import <RP.h> // Both RP and RS have and init: method
- > #import <RS.h>
- >
- > id x;
- >
- > x = [[RP alloc] init:(int) 5];
- >
- > id is totally dynamic, and thus it really does not know which init to use....
- >
- > So, why is it telling me that it is using one method or another...shouldn't
- > this be left up until run-time?
- >
- >
- > Am I doing something wrong to cause this?
-
- Yeah, you're "type overloading" the method "init:". Don't do that.
- Make one of the "-initInt: (int) intVal" and the other one
- "-initObj: (OBJPTR) obj"
-
- ... or something like that.
-
-
- > Thanks,
- >
- >
- > Jack Gidding
- > jack@richsun.cpg.trs.reuter.com
- --
- Jim Mackraz
- jim@oceania.com
-