Article View: comp.std.c++
Article #4101Re: 'const' binding to specifier in declaration list
From: J. Kanze
Date: Thu, 18 Apr 1996 16:42
Date: Thu, 18 Apr 1996 16:42
42 lines
2548 bytes
2548 bytes
In article <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>
kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
|> In article <3173B383.41C67EA6@rstcorp.com> "Aaron S. Binns"
|> <asbinn@rstcorp.com> writes:
|> |> [Moderator's note: This is crossposted to comp.std.c++ and
|> |> comp.lang.c++, and followups have been set to comp.std.c++. mha]
|> |> I recently came across a piece of code that reads:
|> |> class A {
|> |> // contents of class A
|> |> } a1, *a2, const *a3;
|> While I personally wouldn't write anything like this, it is definitly
|> legal.
Actually, on further thought, I don't think it is legal. In the statement:
A const* a3 ;
The const is part of the `declaration-specifiers', and not the
`declarator'. When multiple symbols are declared in the same line, as
here, the list contains declarators, and cannot contain additional parts
of the declaration-specifiers.
A quick check of the grammar shows that the first token of a declarator
must be one of { `*', `(' , <identifier> }. The keyword `const' is none
of these.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<KANZE.96Apr18103420@gabi.gabi-soft.fr>Path:
arc1-ca.pugleaf.net!fido.asd.sgi.com!austernReferences:
<3173B383.41C67EA6@rstcorp.com> <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern From: kanze@gabi-soft.fr (J. Kanze) Newsgroups: comp.std.c++ Subject: Re: 'const' binding to specifier in declaration list Followup-To: comp.std.c++ Date: 18 Apr 1996 09:42:19 PDT Organization: GABI Software, Sarl. Approved: austern@isolde.mti.sgi.com Message-ID: <KANZE.96Apr18103420@gabi.gabi-soft.fr> References: <3173B383.41C67EA6@rstcorp.com> <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de> NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 18 Apr 1996 08:34:20 GMT In-reply-to: kanze@lts.sel.alcatel.de's message of 17 Apr 1996 10:41:47 PDT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMXZw7Uy4NqrwXLNJAQHjtwH/bUDdICpZMboVzSfIK5xdkNScrm7GasM9 gWiY9TJ7ae1d8h5VwpN+CRU+lUaCjaB0j3Os39ZMsmENX3KZKrY/QQ== =imfj Originator: austern@isolde.mti.sgi.com