Re: union protected access

From: Derrick Coetzee (dcnews_at_moonflare.com)
Date: 09/02/04


Date: Thu, 02 Sep 2004 12:59:19 -0400

Paul wrote:
> Derrick Coetzee <dcnews@moonflare.com> wrote in message news:<ch5rr6$qn4$1@news-int2.gatech.edu>...
>
>>Even just having public and private in unions is rather silly, since the
>>presence of even one public field exposes all the others to mutation,
>>breaking encapsulation.
>
> [ . . . ] we can still access private, does this mean public, private,
> protected are useless in C++.

The point of protected and private are not to make it impossible for
someone to access the data, but to make it difficult enough that they
aren't likely to do it accidentally. In a union, it's easy to access the
data as long as a public member is visible, so easy that it could be
done accidentally and cause errors. This is what I mean by breaking
encapsulation in a C++ context.

-- 
Derrick Coetzee
I grant this newsgroup posting into the public domain. I disclaim all
express or implied warranty and all liability. I am not a professional.


Relevant Pages

  • Re: Why Simitis tried so hard?
    ... in the uk the unions aimed at installing a socialist state. ... Again, if it is institutionalized, it is not corruption!! ... this is what constituted the tipping point for Greece. ... there are big private hospitals. ...
    (soc.culture.greek)
  • Stop the Employee NO Choice Act!
    ... Private ballots are the foundation of our democracy. ... unions have respected this right when organizing workers. ... work and at home by organizers intent on obtaining signatures. ...
    (soc.retirement)
  • Re: Union Sundown
    ... unions' fundamental power to bargain for wages. ... "They insist this is the end of unionization in government, ... Unions in the private sector are ... private interest, that of employees, against the public's interest, ...
    (rec.music.dylan)
  • Re: OT Did you get your open season insurance docs yet?
    ... Private industry, which private insurance companies are part of, ... Big cities are dominated by government unions. ... In this case we are talking about government unions. ...
    (rec.boats)
  • Re: Modifying private variables from outside the containing class?
    ... Is it possible to set a value for a private variable from outside the ... breaking encapsulation. ... If the implmentation of A changes, ...
    (microsoft.public.dotnet.languages.csharp)