# AngelScript getters and setters (WIP)

## Recommended Posts

I'm making good progress on the support for getters and setters in AngelScript. I still have some tests to write but I think they are already working pretty well. For that reason I'd like for whoever intend to use these to give the new feature a try, to see if we can root out any potential bugs before I release version 2.17.1. You add getters and setters in objects (both script classes and registered types) by declaring a couple of methods like this:
class MyObject
{
int get_Prop() { /* return the value */ }
void set_Prop(int v) { /* set the value */ }
}

When accessing the member Prop of this class, the correct property accessor method will be called based on what the expression is used for. Observation: Both the get and set methods must have matching types, otherwise the compiler won't know what type to use. Please download the latest revision from the SVN, and let me know if you encounter any problems with the getters and setters.

##### Share on other sites
If you leave out the get, can you make it write only?
If you leave out the set, can you make it read only?

Yes :)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628308
• Total Posts
2981979

• 9
• 9
• 13
• 11
• 12