Topic: Pnteresting problem with namespaces


Author: Gerard Weatherby <gerard.weatherby@snet.net>
Date: 1997/02/11
Raw View
Andrey I. Savov wrote:
>
> I ran into an interesting problem using namespaces in C++. The following
> usage of namespaces appear to be correct (at least I haven't been able to
> disprove this) as far as the language constructs go, however, it creates
> problems in Microsoft C++ compiler.
>
> class A
>    {
>    public:
>    int         a;
>
>    typedef class A B;
>
>    static int tdesc;
>    };
>
> namespace
>    {
>    using A::B;
>
>    int B::tdesc = 56;
>    };
>
> The problem appears to be in using scope resolution operator with
> typedef-ed scope name inside a namespace.
>
> Can you please tell me:
>
> 1. Is this construct legal to use
> 2. Has anyone ever seen problems with such uses of namespaces in other C++
> compilers

Compiles and links using Borland 5.01.

It's not exactly clear to me what the point of this construct is. The
unnamed namespace
doesn't restrict visibility of the static tdesc member, and it's
irritating to have to trace
typedefs to have to figure out that int B::tdesc = 56 is the definition
of the A::tdesc static member.


[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]