This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
How to declare a global friend function from within a class within a namespace
- To: gcc-bugs at gcc dot gnu dot org
- Subject: How to declare a global friend function from within a class within a namespace
- From: Juan Carlos Franzoy <jcfranzoy at ats dot com dot ar>
- Date: Tue, 30 Jan 2001 11:14:58 -0300
I have troubes with the following code, I think it's a bug.
With g++ version 2.95.2 on a Sun/Solaris this code give the message: "b.c:8
parse error before 'operator' ".
#include <iostream>
namespace misc { class Date; } // forward declaration
std::ostream& operator<< ( std::ostream& s, const misc::Date& dt );
namespace misc {
class Date {
friend std::ostream& ::operator<< ( std::ostream& s, const Date& dt
);
};
};
std::ostream& operator<< ( std::ostream& s, const misc::Date& dt ) { return
s; }
I had no problem compiling it with Microsoft VC++.
Juan Carlos Franzoy
Analista Programador
ATS Advanced Technology Solutions
Corrientes 880 Piso 11 Capital Federal
(C1043AAV) Argentina
Tel:+54-11-4393-4345 +54-11-6393-4345, Fax:+ 54-11-4934-7005 +
54-11-6934-7005
JCFranzoy@ats.com.ar
http://www.ats.com.ar