How can I obtain a class type variable from an instance? I want to 
create a second instance of the same descendant class (via the 
constructor, which will take some parameters and make the new instance 
unique)

Tobject.classtype returns TClass (class of TObject) which I first 
assumed would work great. However I cannot seem to do a type conversion 
from TClass to t_mammal_class (class of t_mammal)! So I am stuck here.

I tried just using TClass and skipping t_mammal_class, but then I can't 
use my overriden constructor that takes special parameters.

Thanks in advance,
David.


On Fri 19 Mar 2010, David Emerson wrote:
> Florian Klaempfl wrote:
> > Constructor procvars are indeed not supported but the way to achieve
> > what you want is to use class type variables
> > 
> >   t_mammal_class = class of t_mammal;
> > 
> >   function find_or_create_animal (color : byte;
> >       pass_mammal_type : t_mammal_class) : t_mammal;
> > 
> >   brown_pig := t_pig (pig_pen.find_or_create_animal (brown, t_pig));
> 
> ah, that is exactly what I need. Works perfectly. Thanks much.
> 
> ~D.
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to