Topic: Using declaration


Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1998/07/09
Raw View
Tomasz Truderung wrote:
>
> Hello,
>
> given the following program:
>
>     namespace A {
>         int a;
>     }
>
>     struct B {
>         using A::a;    // error 1
>         static int b;
>     };
>
>     namespace C  {
>         using B::b;    // error 2
>     }
>
> In my opinion it makes sense, but it is not legal
> according to draft C++ standard:

In my opinion, only the first one makes sense. It should not allow
you to access A as B::a, however it would allow member functions
of B to access a without prefixing it with A::.

The second using is IMHO not a good idea and I wouldn't like
it to be allowed.
However, you already can get the same effect with references:

namespace A
{
  int a;
}

struct B
{
  static int b;
private:
  static int& a;
};

int B::a = A::a;

namespace C
{
  int& b=B::b;
}

[...]
---
[ 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              ]