CCircle *circle = new CCircle(10, 15.0);
circle->getPosition()(rand() % mWindow.getWidth(), rand() % mWindow.getHeight(), 0.0);
circle->getVelocity()(rand() % 10 + 1, rand() % 10 + 1, 0.0);
mCircles.push_back(circle);
When I only create one circle it works fine but whenever I create several I get a division by zero run-time error.
Can some one help me why that is?
Thanks
Scanmaster_K
Division by zero
Hi, I got this code:
I don't see any division in that code. Run your program through a debugger and post the actual line of code where the error happens.
-me
-me
Unless circle->getPosition() and circle->getVelocity() return functors, I'm pretty certain that code is invalid. First of all, are you sure that that is the exact code? Secondly, are you sure that's where the divide by zero errors are coming from?
Just noticed that when I take the code out of my initialize function it works fine.
The getPosition returns a reference to a vector class.
The getPosition returns a reference to a vector class.
Quote:Original post by Scanmaster_k
Just noticed that when I take the code oit of the constructor it works fine.
Have you used a debugger to find out exactly where the errors are occuring, yet?
Quote:Original post by Scanmaster_k
The getPosition returns a reference to a vector class.
And the vector class has the () operator overloaded? Why?
The debugger gives the error message at this line:
getWidht and height gives valid return values.
I use the () of my vector class to set the values in the array which hold the data like vec(index, value) or vec(0, 1, 2, 3)
circle->getPosition()(rand() % mWindow.getWidth(), rand() % mWindow.getHeight(), 0.0);
getWidht and height gives valid return values.
I use the () of my vector class to set the values in the array which hold the data like vec(index, value) or vec(0, 1, 2, 3)
Quote:Original post by Scanmaster_k
The debugger gives the error message at this line:circle->getPosition()(rand() % mWindow.getWidth(), rand() % mWindow.getHeight(), 0.0);
getWidht and height gives valid return values.
I use the () of my vector class to set the values in the array which hold the data like vec(index, value) or vec(0, 1, 2, 3)
So you are using it to set the position? A setPosition method would be a lot easier to read.
EDIT: Additionally, is that as deep as the error goes? It doesn't occur in the function called?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement