Sign in to follow this  

Reference Objects vs Value Objects

This topic is 2763 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 am assuming that the difference between reference objects and value objects is that value objects are copied by value (and hence not suitable for large/complex classes) where as value objects are more basic types like vectors. My question is, say I have a 'Player' class. This would be a reference class. Why can I not assign it a constructor/destructor, but HAVE to use a reference counter and factory?

Share this post


Link to post
Share on other sites
The only difference between the factory and the constructor, is that the factory is responsible for allocating the memory as well as initializing it, whereas the constructor is only responsible for initializing the memory that has already been allocated by the caller.

You cannot register a destructor for a reference type, because AngelScript will never call it. AngelScript only calls the Release behaviour when it doesn't use the object anymore. The release behaviour is responsible for destroying the object when there are no more references to it.

Share this post


Link to post
Share on other sites

This topic is 2763 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this