This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How to declare a global friend function from within a class within a namespace



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]