Possible Duplicate:
Why use getters and setters?
while writing class in c++, usually methods are made public, and attributes are made private/public, so that these attributes cant be accessed from outside.
But when we use getters/setters, these attributes can be easily accessed,modified from outside. So, why to make them private/protected in first hand; if we are going to use setters/getters later on to modify.
I have been confused with this question. Nice explanation would be helpful.
Thanks.