A
aaj
Hi all
I'm wrestling my way through OOPs concepts and have a question on set{}. Can
anyone help
From the stuff I've been reading, set and get are accessors to class
properties (i.e. local class variables) which inturn are used to reflect the
state of a particular object.
I can understand using get{} to allow other classes to see the state of an
object, but when would you use set{} to change the state/local data?
In my mind (poor as it is) , I can only imagine the state of an object ever
being changed within the class i.e. An external class executes a method and
the method may or may not adjust the state of the class, depending on the
result of the action.
so I suppose in summary I'm asking why would you use set{} rather than use a
method (other than you don't have to use parenthesis when calling)?
many thanks if anyone can clear up my misunderstanding
thanks
Andy
I'm wrestling my way through OOPs concepts and have a question on set{}. Can
anyone help
From the stuff I've been reading, set and get are accessors to class
properties (i.e. local class variables) which inturn are used to reflect the
state of a particular object.
I can understand using get{} to allow other classes to see the state of an
object, but when would you use set{} to change the state/local data?
In my mind (poor as it is) , I can only imagine the state of an object ever
being changed within the class i.e. An external class executes a method and
the method may or may not adjust the state of the class, depending on the
result of the action.
so I suppose in summary I'm asking why would you use set{} rather than use a
method (other than you don't have to use parenthesis when calling)?
many thanks if anyone can clear up my misunderstanding
thanks
Andy