Re: Error with friend declarations and namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matt Fago <fago@xxxxxxxxxxxxx> writes:

> It seemingly is related to friend injection (-ffriend-injection
> eliminates the message).
>
> C.h:
> ---
> #include <iostream>
> namespace A {
>   namespace B {
>     class C {
>     public:
>       friend std::ostream & operator<< ( std::ostream &os, C &in );
>     };
>   }
> }

This makes the function a friend but does not actually declare the
function.  That is what -ffriend-injection is about: in pre-ISO C++ a
friend declaration served as a declaration, in ISO C++ it does not.

If you want to declare the function, declare it.  Don't just mention it
in a friend declaration.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux