Take address of non-member operator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tassos Souris
    New Member
    • Aug 2008
    • 152

    Take address of non-member operator

    hi

    can i take the address of a non-member in C++ to use it e.g. in ptr_fun() ?

    Code:
    ostream& operator<<(ostream& out, const X& x){
            ....
    }
    then:
    Code:
    list<X> xs;
    
    for_each(xs.begin(), xs.end(), bind1st(ptr_fun(what_here??),cout));
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Use the function name, which in this case is operator<< (in theory any way I confess to not having tried it).

    Comment

    Working...