recursion within a class
Is there something about having a class member function try to call itself that will automatically fail that would prevent recursion within a class and how do you avoid it?
I'm trying to write a c++ conversion of a C program so I can encapsulate a certain functionality within a class, but the functionality relies on recursion to work. But when it comes to the point of making the call it's like it doesn't even run the function and automatically returns a 0. Is this normal? How do I fix it.
I could show you my code if you like but it's awfully convoluted right now.
No, recursion works with member functions just as it does with free functions. Of course, it is always possible to substitute recursion with iteration, using an explicit stack if necessary.
Okay, this was a classic example of me programming too late at night and shooting of the question that my fatigue prevented me from seeing.
I had a line in my recursive function that measured how much time it took to run so that it didn't keep dead ends that I haven't programmed it to be smart enough to find the first time. Of course with debugging so I can step through the program the 1 second time limit was expiring before it iterated once.
So if I could I'd delete this thread. Once again, laserlight, thanks for the quick and knowledgeable reply.