discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why is this casting needed?


From: Nate Smith
Subject: Why is this casting needed?
Date: Fri, 24 Mar 2006 15:17:11 -0500

Hello,

I have two classes, A, and B, each which have "initWithNumber:" methods.
I have another class, C, which accepts an instantiated A object in one
of its constructors. I compile the following 'code':

C *c = [[C alloc] initWithA: [[A alloc] initWithNumber: 5]];

The compiler gives me a warning saying that "initWithNumber:" has two
definitions: one in A, and one in B. If I cast the result of [ A alloc ]
to (A*), no error is reported:

C *c = [[C alloc] initWithA: [(A*)[ A alloc ] initWithNumber: 5]];

Is this a bug or a feature? If GNUstep is using my regular GCC, my GCC
version is 3.4.5. Thanks

Nate






reply via email to

[Prev in Thread] Current Thread [Next in Thread]