c++ - Access members directly or always use getters -


Note: C ++ specific question

I personally find it weird / ugly When a class uses a waiter access to your member data I know that there is no effect of performance, but I do not like to see all those method calls. Is there any strong argument in any way, or is it just one of those things, which is a personal preference and should be left for each coder, or should be controlled arbitrarily in one coding criteria?

Updates: Especially for ' non-public members of a class.

The classmates ready to use have a canary in the Gerers / Setters Khan, which states It tells you that your class is growing improperly, that your class is trying to do very different things, it caters to many purposes where instead of a

In fact, it usually happens when you use your class to store or access your data The use of the part, and another part to act on it. You may want to consider using a standalone class to store and access your data, and the second should provide a high view with a more complex operation with your data.


Comments