Posted by: byates
« on: February 14, 2009, 11:46:13 PM »I am playing with Slick-C classes and have the following question:
What is the most efficient way to add a class instance to an array?
I can do this, but is requires an extra deep copy of the instance:
Thanks!
What is the most efficient way to add a class instance to an array?
Code: [Select]
tcClassType MyArray[];
for(i=0;i<SomeCount;i++)
{
MyArray[i] = new class instance() <- what is the correct syntax???
}
This syntax gives an error:Code: [Select]
for(i=0;i<SomeCount;i++)
{
MyArray[i] = tcClassType(parm1, parm2,...);
}
I can do this, but is requires an extra deep copy of the instance:
Code: [Select]
for(i=0;i<SomeCount;i++)
{
tcClassType MyClassInst(parm1,parm2,...);
MyArray[i] = MyClassInst;
}
Is there a better syntax?Thanks!