Jump to content
  • Advertisement
Sign in to follow this  
Adams555

Messy pointer problem.. (fixed)

This topic is 4822 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

Hello. I have a class, with coordinates for X, Y, and Z. I attached a particle system to an instance of that class by doing something like this.. class Object{ int X; }; class ParticleSystem{ int *X; }; then I do.. PSInstance->X=&OInstance.X; etc, which, as expected, binds the two X values, changing ParticleSystem's X value automatically when Object's X value changes. So far so good. Now, I want to get rid of Object, and I don't know what instance of the particle system is using it... So I figure I'll check if the X,Y, and Z are valid values, that ought to tell me whether or not Object has been deleted. But... I try if (PSInstance->X==NULL){ } but it doesn't return true, when the object with the connected X value is deleted.. Please help, how do I tell when the pointer becomes invalid? Thanks. Adam [Edited by - Adams555 on September 5, 2005 8:21:02 PM]

Share this post


Link to post
Share on other sites
Advertisement
The pointer's not null but it points to null. What you might want is to register the instance of the particle system in your object.

Share this post


Link to post
Share on other sites
Heh.. I REALLY should have thought of registering the instance in my class before. Reguardless, it works very nicely now.. just made and destroyed around 1k of those objects, with no noticable loss of performance :)

Thanks again,

Adam

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!