Topic: Scope Operator Questions


Author: comeau@panix.com (Greg Comeau)
Date: 2000/11/21
Raw View
In article <3A197C24.C6132EBE@gorge.net>, Matt Brunk  <brunk@gorge.net> wrote:
>I've looked in the C++ Standard but am having some difficulty
>determining whether the following are legal.
>
>Consider:
>
>class foo
>{
>public:
>  void foo::bar();
>};
>
>Is this legal?

No.

>This compiles fine with VC++ on Windows and gcc on Linux (gcc gives a
>warning about an extra qualification "foo::" on member 'bar').
>CodeWarrior gives an error: "illegal access/using declaration".

Comeau C++ accepts this too in its relaxed modes, but not in
strict mode.  I would expect the same of the other compilers.

>Consider:
>
>class foo
>{
>public:
>  static void bar();
>};
>
>int main()
>{
>  foo::foo::bar();
>}
>
>Is this legal?
>
>This gives errors with VC++ and gcc but compiles fine with CodeWarrior.
>In fact with CodeWarrior, I can have an unlimited number of "foo::"
>qualifiers. For example, the following compiles without errors:
>
>foo::foo::foo::foo::bar();

I'd have to double check this, but I don't believe that's ok.

- Greg
--
Comeau Computing / Comeau C/C++ "so close" 4.2.44 betas NOW AVAILABLE
TRY Comeau C++ ONLINE at http://www.comeaucomputing.com/tryitout
Email: comeau@comeaucomputing.com / WEB: http://www.comeaucomputing.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://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: wmm@fastdial.net
Date: 2000/11/21
Raw View
In article <3A197C24.C6132EBE@gorge.net>,
  brunk@gorge.net wrote:
> I've looked in the C++ Standard but am having some difficulty
> determining whether the following are legal.
>
> Consider:
>
> class foo
> {
> public:
>   void foo::bar();
> };
>
> Is this legal?

No.  8.3p1 says that you can only qualify a declarator when
it is used to define an entity outside its class/namespace or
in a friend declaration.  The declaration of a class member
inside the class definition is not one of those cases.

> This compiles fine with VC++ on Windows and gcc on Linux (gcc gives a
> warning about an extra qualification "foo::" on member 'bar').
> CodeWarrior gives an error: "illegal access/using declaration".
>
> Consider:
>
> class foo
> {
> public:
>   static void bar();
> };
>
> int main()
> {
>   foo::foo::bar();
> }
>
> Is this legal?
>
> This gives errors with VC++ and gcc but compiles fine with
CodeWarrior.
> In fact with CodeWarrior, I can have an unlimited number of "foo::"
> qualifiers. For example, the following compiles without errors:
>
> foo::foo::foo::foo::bar();

This is currently legal.  However, it will cease being legal
when the first Technical Corrigendum is approved.  See
http://www.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#147.
The resolution for that issue says that C::C is considered to
name the constructor for class C, and you can't use a
constructor name as part of a nested-name-specifier.

--
William M. Miller, wmm@fastdial.net
Vignette Corporation (www.vignette.com)


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ 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.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Matt Brunk <brunk@gorge.net>
Date: 2000/11/20
Raw View
I've looked in the C++ Standard but am having some difficulty
determining whether the following are legal.

Consider:

class foo
{
public:
  void foo::bar();
};

Is this legal?

This compiles fine with VC++ on Windows and gcc on Linux (gcc gives a
warning about an extra qualification "foo::" on member 'bar').
CodeWarrior gives an error: "illegal access/using declaration".

Consider:

class foo
{
public:
  static void bar();
};

int main()
{
  foo::foo::bar();
}

Is this legal?

This gives errors with VC++ and gcc but compiles fine with CodeWarrior.
In fact with CodeWarrior, I can have an unlimited number of "foo::"
qualifiers. For example, the following compiles without errors:

foo::foo::foo::foo::bar();

Regards
--
Matt

---
[ 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.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: mwron@metrowerks.com (MWRon)
Date: 2000/11/20
Raw View
In article <3A197C24.C6132EBE@gorge.net>, brunk@gorge.net wrote:

>I've looked in the C++ Standard but am having some difficulty
>determining whether the following are legal.
>
>Consider:
>
>class foo
>{
>public:
>  void foo::bar();
>};
>
>Is this legal?

No it is not legal

>This compiles fine with VC++ on Windows and gcc on Linux (gcc gives a
>warning about an extra qualification "foo::" on member 'bar').
>CodeWarrior gives an error: "illegal access/using declaration".

I think we may allow it for Windows code because there is legacy code with
this illegal use.

>Consider:
>
>class foo
>{
>public:
>  static void bar();
>};
>
>int main()
>{
>  foo::foo::bar();
>}
>
>Is this legal?

Yes

>This gives errors with VC++ and gcc but compiles fine with CodeWarrior.
>In fact with CodeWarrior, I can have an unlimited number of "foo::"
>qualifiers. For example, the following compiles without errors:
>
>foo::foo::foo::foo::bar();

Yes this is legal, each class has an implicit typename member with the
classes own name, so
(in)finite  xxxxxx::xxxxxx::... qualifications are legal.

Ron

--
CodeWarrior PersonalJava Edtion
The speed, integration, and flexibility of the product are truly impressive.
Java Report Online
http://www.javareport.com/html/from_pages/product_review.cfm?articleID=1616

Metrowerks  "Software Starts Here"   MWRon@metrowerks.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://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]