Topic: parsing ambiguity - scope resolution operator


Author: Steve Clamage <stephen.clamage@sun.com>
Date: 1999/11/30
Raw View
Francis Glassborow wrote:
>
> In article <383BE366.65BC@worldnet.att.net>, Tamasa Mahapatra <saroj-
> tamasa@worldnet.att.net> writes
> >Hi,
> >
> >If I have a construct like
> >
> >C :: b and C is a class and b is an object, how do I know if
> >the scope resolution operator applies to C (member b in class
> >or namespace C) or b (object in global scope of type C or start
> >of a function b returning C)?
>
> Because the syntax does not allow you to declare global objects that
> way.

That's not quite correct. There is an ambiguity in the syntax, and
the meaning of
 C :: b;
is not well-defined. It is best if you don't need a global qualifier
on the declarator. If you do, use parens to disambiguate:
 C (::b); // declares global b of type C
 C::b (::a); // declares global a of type C::b
--
Steve Clamage, stephen.clamage@sun.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Tamasa Mahapatra <saroj-tamasa@worldnet.att.net>
Date: 1999/11/27
Raw View
Hi,

If I have a construct like

C :: b and C is a class and b is an object, how do I know if
the scope resolution operator applies to C (member b in class
or namespace C) or b (object in global scope of type C or start
of a function b returning C)?

Thanks,
Saroj
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/11/27
Raw View
In article <383BE366.65BC@worldnet.att.net>, Tamasa Mahapatra <saroj-
tamasa@worldnet.att.net> writes
>Hi,
>
>If I have a construct like
>
>C :: b and C is a class and b is an object, how do I know if
>the scope resolution operator applies to C (member b in class
>or namespace C) or b (object in global scope of type C or start
>of a function b returning C)?

Because the syntax does not allow you to declare global objects that
way.


Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation


[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]