• Advertisement
Sign in to follow this  

Problem with recursion

This topic is 3860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a bit of a problem with my code.. I've defined a bunch of classes to read skeleton information from a text file..:- Skeleton - defines the class to store the skeleton information and a pointer to the root bone of the skeleton Joint - defines a joint of the skeleton which contains various bits of joint information to be read in from the file as well as a linked list of children (of the same type) Tokenizer - defines the class used to read the token data from the text file to fill in the data for every "Joint" in the skeleton hierarchy - When my application calls Skeleton::Load() it opens the text file to be read and calls Joint::Load() on the root Joint member (passing the tokenizer as a parameter).. - Joint::Load() reads the base set of joint information (using the tokenizer) for the current joint and then checks in the text file for a child joint.. If one is found it creates a new Joint object and adds it to the children linked list of the current joint before calling Joint::Load() on the child joint (passing the tokenizer as a parameter).. - After reading the information for the child (using the tokenizer) a check for a child of the current joint is made.. When no child is found the Joint::Load() function returns which does something strange.. Before returning to the previous function in the call stack for some reason the tokenizer's destructor is called which destroys it so that when we return to check for the next token the application crashes.. Is there any specific reason this is happening (especially since the tokenizer is a child of Skeleton class and only a reference is beng passed along to each call to Load() )...? Is there anyway I can get around this? (otherwise it does kind of defeat the purpose of the recursivity) Sorry my explaination wasn't great, Hope you can help.. Archangelmorph

Share this post


Link to post
Share on other sites
Advertisement
Any chance you're passing the tokenizer by value (and not by reference or via a pointer) to Joint::Load()? EDIT: Just noticed that you say it is being passed by reference but maybe double-check this because it sounds like this is the problem.

Also, if you post the code to Joint::Load() it might give us more information about your problem.

Share this post


Link to post
Share on other sites
Let's see the code anyway, please. (My spider sense is tingling...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement