Sign in to follow this  
Ameise

Reference Objects vs Value Objects

Recommended Posts

Ameise    1148
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
WitchLord    4677
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

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