[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swarm-Support] passing information between classes
From: |
Rick Riolo |
Subject: |
Re: [Swarm-Support] passing information between classes |
Date: |
Tue, 12 Oct 2004 09:51:25 -0400 (EDT) |
Derek,
First just to be sure we are on the same page...
note that these
id aClassA;
ClassA *aClassA;
don't create instances, they just create variables of type id
for storing pointers to objects.
Given that...
The basic difference between the two is that the "id" type
doesn't tell the compiler what kind of object you are
going to be storing pointers to.
Eg you could have
id aClassA;
aClassA = [ClassA create: ...];
aClassA = [ClassB create: ...];
and that would be just fine.
But with the second form
ClassA *aClassA;
you are telling the compiler you plan to only store
poitners to ClassA instances, so in that case
ClassA *aClassA;
...
aClassA = [ClassB create: ...];
would give a complaint from the compiler, because you are
createing (with the create: message) an instance to a ClassB
object and trying to store the pointer to that instance
in the variable aClassA, which you had declared as only for
pointers to ClassA objects.
- r
Rick Riolo address@hidden
Center for the Study of Complex Systems (CSCS)
4477 Randall Lab
University of Michigan Ann Arbor MI 48109-1120
Phone: 734 763 3323 Fax: 734 763 9267
http://cscs.umich.edu/~rlr
On Tue, 12 Oct 2004, Derek Farren wrote:
> Date: Tue, 12 Oct 2004 03:24:46 -0300
> From: Derek Farren <address@hidden>
> Reply-To: Swarm Support <address@hidden>
> To: address@hidden
> Subject: [Swarm-Support] passing information between classes
>
> Hello everybody.
>
> I have a doubt about passing information between classes. It ends on a
> specific question: Whats the diference between creating an instance of the
> class "ClassA" via id aClassA and ClassA * aClassA ?
>
> Sometimes both ways work, but some other (when the imported class is
> ModelSwarm) just the first choice works.
>
> Thanks, Derek
>
>
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support
>