home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / cplus / 1781 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.5 KB  |  48 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: Ambiguity in member pointer declaration
  5. Message-ID: <1992Dec15.011359.17235@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References:  <PNORI.92Dec14161301@hyperion.lsi-j.co.jp>
  10. Date: Tue, 15 Dec 92 01:13:59 GMT
  11. Lines: 35
  12.  
  13. |> 
  14. |> Assuming X, Y and Z are class names, how should
  15. |> 
  16. |>     X::Y::Z::*foo;
  17. |> 
  18. |> be interpreted?
  19. |> 
  20. |> 1. foo is a pointer to member of class ::Y::Z of type X.
  21. |>    ('X' is a decl-specifier and '::Y::Z::*foo' is a declarator)
  22. |> 
  23. |> 2. foo is a pointer to member of class ::Z of type X::Y.
  24. |>    ('X::Y' is a decl-specifier and '::Z::*foo' is a declarator)
  25. |> 
  26. |> 3. X::Y::Z is a decl-specifier and ::*mptr is an error.
  27. |> 
  28.  
  29. The is a simpler potential ambiguity lurking in the use of "::" in declarations.
  30.  
  31.     X::f() { ... } 
  32.  
  33. Is the a declaration of "X::f" (implicitly returning int), or of "::f"
  34. (returning X).  To avoid this ambiguity there is a rule that a declarator
  35. may not begin with "::".  Actually there isn't a rule per se. The grammar
  36. doesn't contain any rules that derive a declarator starting with "::".
  37. And that omission is deliberate.
  38.  
  39. So answer to the question is that non of the above interpretations
  40. is possible.  X::Y::Z::*foo, is a declartor and since no explicit
  41. typespec is present int is assumed.  This means that you declaring
  42. "foo" as a pointer to int member of X::Y::Z.  
  43.  
  44.     -- Jerry Schwarz.  
  45.  
  46.  
  47.  
  48.