Re: union protected access

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


Date: Wed, 01 Sep 2004 21:07:48 -0400

Martin Vorbrodt wrote:

> why is the protected access even allowed for unions? no inheritance can take
> place anyways, why not just have public and private only?

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. Such specifiers in unions are an artifact of the
standard's attempt to unify class, struct, and union as all being forms
of an abstract object description concept, and giving them parallel
syntaxes. One could say this simplifies compiler implementations, but
this is dubious.

Were I designing it, I think I would allow only one of two choices:
1. All members are public; the C-style union
2. All members are private; handy for constructing tagged unions with
computed tags

-- 
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: union protected access
    ... >>Even just having public and private in unions is rather silly, ... >>presence of even one public field exposes all the others to mutation, ... >>breaking encapsulation. ...
    (comp.lang.cpp)