Hello, I have a vector to draw some squares to the screen and my program compiles fine but when I run it, it pops up a window that says "Unhandled exception at 0x5a2b5017 in BeerPong2.exe: 0xC00000FD: Stack overflow." I know the memory locations are useless to help, but I wanted to put the whole message up there and my compiler gives me "The program ' BeerPong2.exe: Native' has exited with code -1073741510 (0xc000013a)." So I've heard that a stack overflow means there is too much recursion, so I had all of this in the initialization function because I figured that it was because I was using the same function in itself. So I moved it out of the initialization and made it its own function and called it in the initialization, but I got exactly the same messages. So does anyone know a way to reduce recursion? Or should I make a new class and put this in it? Or any other suggestions would help.
Well to be honest, I wasn't sure I was using recursion, but when I searched the error messages online, most of the posts said when you get a stack overflow, it means you have too much recursion. So if this is not what you're asking, then I have recursion because I want the bottle to be drawn to the screen as it is called. As to where, I was kind of curious myself, I originally used all of this function in the initialization function, and then I got the error messages, so I moved everything to it's own function to try to fix it, but I got the same error messages. and I don't understand your analogy, is that not how you are supposed to call a vector?
Well to be honest, I wasn't sure I was using recursion
You are not. At least not in this function.
So if this is not what you're asking, then I have recursion because I want the bottle to be drawn to the screen as it is called.
Feel free to look up the meaning of recursion.
I don't understand your analogy, is that not how you are supposed to call a vector?
In Bottle::DrawBottle, you create a local vector of 244 bottles and draw them. Typically a "draw" function for an object should only "draw" the "bottle" it was invoked on. Then again, it's hard to see why this would be a member of a class since it doesn't access any class members at all. Is Bottle a namespace?
@OP: run your program trough a debugger and perform a backtrace when it crashes.
If you have `too much recursion' you'll see quite a long call stack.
Regardless, it would tell you where the crash occurs, so post that function.