|
-
December 19th, 2011, 10:12 AM
#5
Re: What does this do...?
 Originally Posted by Peter_B
Yes, it is just a bit of syntactic sugar so you can write your code like, e.g.:
Code:
a.X = 5; <-- uses 'setter'
b = a.X;<-- uses 'getter'
instead of
Code:
a.SetX(5);
b = a.GetX();
It is useful when you start off with a class in which some of the data members are directly exposed, but then you realise (maybe through changing requirements) that some validation is needed. Then you can just define the setter and getter methods but don't need to change the code which accesses the data members.
No, it is purely a different syntax to do what you would previously have done using GetX(), SetX() methods.
Perfect!
Thanks so much for you help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|