Hi all,
ive bumped my head against a wall pretty hard and cannot figure a solution in java for this:
int numberOfObjects = 10;
ObjectA* currentObj;
for (int i = 0; i < numberOfObjects; i++) {
currentObj = &parentObject.node[i];
...
}
Any ideas?
And this one, is getting on my nerves:
int mem_size = sizeOf(obj);
obj = (ObjectA) MemoryAllocaAndClear(mem_size);
:?
Edit: Changed Spelling of title
It’s just getting a reference to the ObjectA, so it’s
int numberOfObjects = 10;
ObjectA currentObj;
for (int i = 0; i < numberOfObjects; i++) {
currentObj = parentObject.node[i];
...
}
However, now currentObj references the same memory as parentObject.node
so if you don't want them to be the same you might want to clone the parentObject.node
awsomes, i edited the post while you were typing, i didn’t expect a reply so fast, any ideas about the other problem?
int mem_size = sizeOf(obj);
obj = (ObjectA) MemoryAllocaAndClear(mem_size);
ObjectA obj = new ObjectA();
serious? i must have hit my head pretty hard! 8-O, thx monkeyman
That’s just one of the annoyances of C/C++, there are so many ways to allocate memory. malloc,calloc,new, etc, etc. Java… new.