On 9 Sep 2005 17:15:08 -0700, "Shezan Baig" <sh************@gmail.com> wrote:
john smith wrote: I was looking at some code that someone had written, and they had a class
with all static attributes.
Can someone please enlighten me why someone would do that? Doesn't that
break the rule of encapsulation?
I have always been used to seeing accessors and mutators instead of directly
accessing an attribute to change or
access the variable.
Thanks in advance for any insight.
Probably just for scoping reasons. Alternatively, they could have just
used a namespace, but maybe there was some reason to prevent it being
re-opened?
Right. I've done that to get around an old compiler that has unreliable
namespace support.
By the way, John, how do static variables break the rule of encapsulation?
The use of accessors and mutators is a good idea, but there are times that you
want to let other entities (especially other classes belonging to a common
library) access your members directly for efficiency or even clarity.