Article View: comp.sys.next.programmer
Article #771Re: Multiple init: functions defined
From: Kenneth Lerman
Date: Sat, 05 Sep 1992 17:30
Date: Sat, 05 Sep 1992 17:30
62 lines
2124 bytes
2124 bytes
In article <3575@richsun.cpg.trs.reuter.com> jack@richsun.cpg.trs.reuter.com (Jack Gidding) writes: ... |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' The problem is that the compiler doesn't know which init: to use. It must either know the type of the receiver or the two methods must have identical types. | | |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? Yes, it should, but the compiler must generate code which is equivalent to a function call. To do this, it must know the types of the arguments. Since the types are different in this case, it doesn't know what to generate. | | |Am I doing something wrong to cause this? | | Yes, you are. |Thanks, | | |Jack Gidding |jack@richsun.cpg.trs.reuter.com Ken -- Kenneth Lerman ...!uunet!casey!gaboon!seltd!lerman Systems Essentials Limited (203)426-4430 55 Main Street Newtown, CT 06470
Technical Details
Message-ID:
<23@seltd.UUCP>Path:
arc1-ca.pugleaf.net!sparky!uunet!casey!gaboon!seltd!lermanReferences:
<3575@richsun.cpg.trs.reuter.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!casey!gaboon!seltd!lerman From: lerman@seltd.UUCP (Kenneth Lerman) Newsgroups: comp.sys.next.programmer Subject: Re: Multiple init: functions defined Message-ID: <23@seltd.UUCP> Date: 5 Sep 92 17:30:51 GMT References: <3575@richsun.cpg.trs.reuter.com> Reply-To: lerman@seltd.UUCP (Kenneth Lerman) Organization: Systems Essentials Limited Lines: 62