From -4314035762965560284
X-Google-Thread: f78e5,51456c3eb8f9490e
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!news.maxwell.syr.edu!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "mark" <markw65@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: Copy Constructor Confusion!
Date: Thu, 17 Aug 2006 11:28:31 CST
Organization: http://groups.google.com
Lines: 54
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1155753523.459377.147180@m79g2000cwm.googlegroups.com>
References: <1155645873.296811.3890@74g2000cwt.googlegroups.com>
   <hPkEg.12700$j7.324766@news.indigo.ie>
   <ebsor6$jbq$1@news.datemas.de>
   <1155663179.843769.44420@b28g2000cwb.googlegroups.com>
   <4kh3o8Fc528lU1@individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1155753528 12427 127.0.0.1 (16 Aug 2006 18:38:48 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 16 Aug 2006 18:38:48 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: m79g2000cwm.googlegroups.com; posting-host=207.135.74.34;
   posting-account=kmJZpwwAAADTaEqNJ8z_rfhCwbaAxYpY
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
	processed by UCSD_GL-v2.1 on mailbox8.ucsd.edu;
	Wed, 16 August 2006 11:38:49 -0700 (PDT)
X-Spamscanner: mailbox8.ucsd.edu  (v1.6 Aug  4 2005 15:27:38, -2.3/5.0 3.0.4)
X-MailScanner: PASSED (v1.2.8 67228 k7GIcn7Z013008 mailbox8.ucsd.edu)
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:3316


Matthias Hofmann wrote:
> "mark" <markw65@gmail.com> schrieb im Newsbeitrag
> news:1155663179.843769.44420@b28g2000cwb.googlegroups.com...
> >
> > "Victor Bazarov" wrote:
> >> Shouldn't this be moved to a .lang. newsgroup?  Just checking...
> >>
> >> Frederick Gotham wrote:
> >> > Thomas posted:
> >> >
> >> >> Hello fellow programmers!
> >> >>
> >> >> I have a c++ line:
> >> >>
> >> >> X x = X();
> >> >>
> >> >> Does the standard say that the class X must have a public copy
> >> >> constructor for this to be legal, even if the copy constructor never
> >> >> gets called?
> >> >
> >> >
> >> > Yes, although it gives explicit permission to the compiler to elide
> >> > the creation of the redudant temporary object. Even if the temporary
> >> > is elided, the copy-constructor must still be public.
> >>
> >> Not "public", *accessible*.  If the "c++ line" above appears inside
> >> a friend function, it would work just fine with a private copy c-tor.
> >
> > Yes.
> >
> >> If it appears inside a member of a derived class, "protected" should
> >> suffice.
> >
> > Really?
>
> Yes, see section 11/1: "A member of a class can be [...] protected; that is,
> its name can be used only by members and friends of the class in which it is
> declared, and by members and friends of classes derived from this class."

You left off the important part of the sentence (see 11.5), which says:

. Except when forming a pointer to member (5.3.1), the access must be
through a pointer to, reference to, or object of the derived class
iteself (or any class derived from that class) (5.2.5).

Mark Williams

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



