First Steps: Dynamic class instantiation

Julio César Carrascal Urquijo jcesar at phreaker.net
Sun Jan 28 09:40:04 PST 2007


Thomas wrote:
> $selected = 1;
> $classes = array('class1','class2');
> $className = $classes[$selected];
> $object = new $className;
> 
> Thanks for any help.
> 
> Thomas


This version is very similar an more efficient though the array 
initialization is more verbose.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070128/fa69a1f5/attachment.ksh>


More information about the Digitalmars-d mailing list