Re: union protected access
From: Derrick Coetzee (dcnews_at_moonflare.com)
Date: 09/02/04
- Next message: cylin: "Re: How many bytes does a vector have?"
- Previous message: Mabden: "Re: Tutorial for beginner/ Tutorial voor beginner"
- In reply to: Martin Vorbrodt: "union protected access"
- Next in thread: Paul: "Re: union protected access"
- Reply: Paul: "Re: union protected access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: cylin: "Re: How many bytes does a vector have?"
- Previous message: Mabden: "Re: Tutorial for beginner/ Tutorial voor beginner"
- In reply to: Martin Vorbrodt: "union protected access"
- Next in thread: Paul: "Re: union protected access"
- Reply: Paul: "Re: union protected access"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|