Jump to content
  • Advertisement
Sign in to follow this  
39ster

Changing the pointer of a class member

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

Alright say i have a class that looks like this: AngelScript
class Blah
{
  float x;
  float y;
}
Than i create an instance of it using CreateScriptObject() and i now want to change the pointer of the x and y to my own x and y. Like this: C++
float x, y;
(float*)instance->GetPropertyPointer(0) = &x
(float*)instance->GetPropertyPointer(1) = &y;
What happens to the x and y that angel script created in CreateScriptObject()? Does it get freed?

Share this post


Link to post
Share on other sites
Advertisement
GetPropertyPointer() returns a pointer to the property so that you can read it's value or overwrite it. It doesn't let you change the actual location of the property.

Share this post


Link to post
Share on other sites
Oh yeah. I was actually wondering how could that be possible until i looked at the examples of "GetReturnPointer()" and saw they were actually changing the value, not the pointer. It was the pointers to pointers that was confusing me.

Share this post


Link to post
Share on other sites
The name of the method doesn't help much either. I'm considering renaming it, e.g. to GetPointerToProperty().

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!