Quote:Original post by Smack0007
This is true but I like to do things like:
*** Source Snippet Removed ***
So then I can do things like:
*** Source Snippet Removed ***
You would only want to do this with member variables that can be edited freely.
Using the C# way, it would look like:
public class Foo{ private Point point; public point Location { get { return point; } set { point = value; } }}Console.Writeline("Location is: ", fooInstance.Location);
Works perfect, and I love it more than having to add () all the time. Also, if you write your own control, using properties allows the developer to change the behaviour in the forms editor, instead in code.
And anon is right, the code you showed begs to make the X/Y variables public, as returning int& from a function gives you full-access to them, begging to be messed up during runtime.
Also, you use properties because if you need sanity checking later, you edit the property and the usage stays the same.
Toolmaker