problem with: namespace N { class N {...}; }
Alexander Zvyagin
zvyagin@gamspc7.ihep.su
Sat May 6 12:17:00 GMT 2000
Dear GCC developers,
I have this code (and I hope it is correct C++ code):
class A {};
namespace N
{
class B { friend A operator>>(A,B); }; // -B-
class N { friend A operator>>(A,N); }; // -N-
}
A N::operator>>(A, N::B) { return A(); } // -B-
A N::operator>>(A, N::N) { return A(); } // -N-
$ g++ -c a1.c
a1.c:7: type specifier omitted for parameter
a1.c:7: `N::operator >>(A)' should have been declared inside `N'
a1.c:7: `N::operator >>(A)' must take exactly two arguments
If you remove lines marked with -B- or with -N- then gcc will compile the
code.
The same problem exists with this code (try to remove marked lines):
class A {};
namespace N
{
class B {}; void f(B); // -B-
class N {}; void f(N); // -N-
}
void N::f(N::B) {} // -B-
void N::f(N::N) {} // -N-
$ g++ -c a2.c
a2.c:7: `B' is not a member of type `N::N'
a2.c:7: variable or field `f' declared void
a2.c:7: `int N::f' redeclared as different kind of symbol
a2.c:5: previous declaration of `void N::f(N::N)'
a2.c:7: syntax error before `{'
I use gcc version 2.95.2 19991024 (release).
With best wishes,
Alexander Zvyagin.
More information about the Gcc-bugs
mailing list