Topic: question on namespaces


Author: klaus@diamant.uucp ()
Date: 16 Aug 1993 08:03:53 GMT
Raw View


I'm posting this for a friend who has problems getting his postings
out. If you want to reply directly don't use my address, use her
address (see below). Thanks.



======================================================================

I'm not sure whether I understood the namespace concept thoroughly.

If I define two namespaces:

   namespace X { ... class A { ... }; .... }
   namespace Y { ... class A { ... /* another definition */ ... }; ... }

How can I use them?

   using namespace X; // using-directive
   using Y::A;  // using-declaration

Does this cause an ambiguity for class A? I guess it does, but I'm not sure.

The only hint I found in Bjarne Stroustrup's proposal was the following:

"If more than one local declaration or using-declaration declares a name,
all those names must refer to functions."

Does this rule aplly? In the above example I have a using-DIRECTIVE and
a using-declaration both declaring the name of CLASS "A".

Does anybody know whether my example will cause an error or not?


+------------------------------------------------------------------------------+
| angelika.langer@mch.sni.de             | SIEMENS NIXDORF Information Systems |
| Angelika Langer                        | SU BS2000 SD225 (C-/C++ Compilers)  |
|                                        | Otto-Hahn-Ring 6                    |
|                                        | D-81739 Muenchen                    |
|                                        | Germany                             |
|                                        | Tel. +49 89 636-40693               |
|                                        | Fax  +49 89 636-40140               |
+------------------------------------------------------------------------------+






Author: ark@alice.att.com (Andrew Koenig)
Date: 17 Aug 93 00:05:33 GMT
Raw View
In article <24nf19$c42@horus.mch.sni.de> klaus@diamant.uucp writes:

> If I define two namespaces:

>    namespace X { ... class A { ... }; .... }
>    namespace Y { ... class A { ... /* another definition */ ... }; ... }

> How can I use them?

>    using namespace X; // using-directive
>    using Y::A;  // using-declaration

> Does this cause an ambiguity for class A? I guess it does, but I'm not sure.

Yes, but not until you actually try to use class A.

--
    --Andrew Koenig
      ark@research.att.com