Dec 13, 2012 at 11:23pm Dec 13, 2012 at 11:23pm UTC
Hi everybody and, I got a trouble about implementing a reversed loop.
It looks like :
1 2 3 4
unsigned char size = Getsize();
for (; size >= 0;size--){
Class[size]->free(); delete Class[size];
}
I tried to fix it many times but I couldn't... :(
Does anybody know?
Last edited on Dec 13, 2012 at 11:36pm Dec 13, 2012 at 11:36pm UTC
Dec 13, 2012 at 11:32pm Dec 13, 2012 at 11:32pm UTC
Are the objects in the Class container dynamically allocated pointers? If you're using .
to access members, then their not even pointers to begin with. How does that code even compile?
Dec 13, 2012 at 11:35pm Dec 13, 2012 at 11:35pm UTC
This is a demonstration example. Actually, the loop causes crash. Why?
Dec 13, 2012 at 11:39pm Dec 13, 2012 at 11:39pm UTC
Thanks Cubbi! The problem now has been solved. Actually It gives me a headache...
Dec 14, 2012 at 10:21am Dec 14, 2012 at 10:21am UTC
Hmm...Currently I'm still using the code :
for (unsigned char i = 0; i < size; i++){[...]}
The code (improved) :
for (--size;;){[...](!--size)break ;}
Output debug size example :
Size : 8
Size : 255
Size : .... // Crash!!!!
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Perhaps this is a core error C++ itself???
Last edited on Dec 14, 2012 at 10:21am Dec 14, 2012 at 10:21am UTC