swarm-support
[Top][All Lists]
Advanced

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

Questions on the return statement


From: Fabio Mascelloni
Subject: Questions on the return statement
Date: Thu, 04 Mar 1999 10:01:33 +0100

Suppose I declare such an instance variable :
 
unsigned  *inst;

Then I initialize it to some value:

- intitInstVar:(unsigned) length
{
    inst=calloc ( length, sizeof (unsigned));
    //init in some way with some values
   return self;
}

After that I implement a method that could be invoked by objects of unrelated classes and that returns the instance variable:

-(unsigned *) getInstVar
{
   return inst;
}

The question is: does getInstVar returns a copy of the object or simply a reference to it ?
If it simply returns a reference, how can I make it return a copy of the object ?
In J.J Merelo's Breeder there's a method to get the genotype of a chromosome:

- getGenotype
{
    return (id) genotype;
}
where genotype is defined as  unsigned char *genotype.Is this the right way?
 

Fabio.


reply via email to

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