How to overload the ostream operator << to make it work with log4cxx in C++?

前端 未结 3 1774
甜味超标
甜味超标 2020-12-19 01:50

Say I have a class A and an operator<< declared like so:

// A.h
class A
{
    // A stuff
};
std::ostream& operator<<(std::ostream& os, co         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 02:49

    You could try declaring your operator << in namespace std (that's legal, since you're passing an instance of your user-defined type):

    namespace std {
       ostream& operator<<(ostream& os, const A& a);
    }
    

提交回复
热议问题