Re: Valid C++?
* Boris:
> Is this a valid C++ program (according to the C++ standard)? I ask as
> I'm trying to port a Windows library to Solaris, and the Solaris C++
> compiler reports an error (The name x is ambiguous in ns1: ns2::x and
> ns1::x). The code below reproduces the problem, and I wonder now if I
> have to adapt the code or submit a bug report to Sun?
>
> namespace ns1 {
> struct x { };
> }
>
> namespace ns2 {
> using namespace ns1; // If this line is removed ...
> void x(); // ... or this line the code compiles.
> struct x { };
> }
>
> int main()
> {
> struct ns2::x x;
> }
As I recall the code is formally valid but dumb.
Since it's dumb I won't make the effort to look up the standard's
guarantees for you.
Rename.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
|