🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1238

Re: Ambiguity in member pointer declaration

#1238
From: Jerry Schwarz
Date: Tue, 15 Dec 1992 01:13
32 lines
1580 bytes
|> 
|> Assuming X, Y and Z are class names, how should
|> 
|> 	X::Y::Z::*foo;
|> 
|> be interpreted?
|> 
|> 1. foo is a pointer to member of class ::Y::Z of type X.
|>    ('X' is a decl-specifier and '::Y::Z::*foo' is a declarator)
|> 
|> 2. foo is a pointer to member of class ::Z of type X::Y.
|>    ('X::Y' is a decl-specifier and '::Z::*foo' is a declarator)
|> 
|> 3. X::Y::Z is a decl-specifier and ::*mptr is an error.
|> 

The is a simpler potential ambiguity lurking in the use of "::" in declarations.

	X::f() { ... } 

Is the a declaration of "X::f" (implicitly returning int), or of "::f"
(returning X).  To avoid this ambiguity there is a rule that a declarator
may not begin with "::".  Actually there isn't a rule per se. The grammar
doesn't contain any rules that derive a declarator starting with "::".
And that omission is deliberate.

So answer to the question is that non of the above interpretations
is possible.  X::Y::Z::*foo, is a declartor and since no explicit
typespec is present int is assumed.  This means that you declaring
"foo" as a pointer to int member of X::Y::Z.  

    -- Jerry Schwarz.  
Technical Details
Message-ID: <1992Dec15.011359.17235@lucid.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
References: <PNORI.92Dec14161301@hyperion.lsi-j.co.jp>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
From: jss@lucid.com (Jerry Schwarz)
Subject: Re: Ambiguity in member pointer declaration
Message-ID: <1992Dec15.011359.17235@lucid.com>
Sender: usenet@lucid.com
Reply-To: jss@lucid.com (Jerry Schwarz)
Organization: Lucid, Inc.
References:  <PNORI.92Dec14161301@hyperion.lsi-j.co.jp>
Date: Tue, 15 Dec 92 01:13:59 GMT
Lines: 35