c++ - Coexistence among global operator<< and member operator<< -


does know how make these 2 overloaded operators coexist?

#include<iostream>   template< typename t >  class a;   template< typename t >  std::ostream& operator<<( std::ostream& o, const a<t>& e );   template< typename t >  class  {     a& operator <<( const a& e );     friend std::ostream& operator<< <>( std::ostream& o, const a<t>& e );  };   int main()  {     // program    return 0;  }   // def a<t>::a& a::operator <<( const a& e );  // def std::ostream& operator<< <>( std::ostream& o, const a<t>& e ); 

error:

$ g++ prov.cpp -o prov prov.cpp:13:33: error: declaration of ‘operator<<’ non-function prov.cpp:13:33: error: expected ‘;’ @ end of member declaration prov.cpp:13:36: error: expected unqualified-id before ‘<’ token 

i’m sorry bad english. reason write little.

greeting , thanks!

i think want:

friend std::ostream& operator<< <t>( ... ); 

in friend declaration. (i'm not sure: policy has been define friend inline, didn't matter if template or not. looks examples in standard.)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -