Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
What is the last letter in the word "SlickEdit":
How many LETTERS are in the following? "a1b2c3":
Which number is missing?  "12345689":

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

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?
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!