THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/08/2011 at 11:30, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hey guys,
Noobish question.
I'm having trouble creating a dynamic array with C++ that is holding objects in it.
I can make dynamic integer arrays just fine. But it doesn't work when I use the BaseObject type for my array:
BaseObject *countsteps = doc->SearchObject("Steps")->GetDown(); //Get the first child under the parent object called "Steps"
int stepcount = 0;
BaseObject *steparr[3]; //This works....But it's not dynamic
//BaseObject *steparr[stepcount]; //<---------Does not work!!!
while(countsteps)
{
stepcount ++; //Counts the number of child objects(steps) in the group
countsteps = countsteps->GetNext();
}
BaseObject *steps = doc->SearchObject("Steps")->GetDown(); //Get the first child of the group
int j=0;
for(j=0; j < stepcount; j++)
{
steparr[j] = steps; //Fills the array with the child objects each time it loops
steps = steps->GetNext();
}
GePrint(steparr[0]->GetName());
GePrint(steparr[1]->GetName());
GePrint(steparr[2]->GetName());
All this code does is fill an array with the child objects that are under a parent object.
It works fine if I use a set constant array size. But I'd like to know how to make it dynamic so I don't have to set the array size to some arbitrary higher value than what I need.
-ScottA