Topic: overload resolution of global vs member op fns


Author: mcg@wheezy.CS.Berkeley.EDU (Michael C. Greenspon)
Date: 1997/01/06
Raw View
If a program overloads both member and global operators for a class, which
is invoked? I.e.,

struct S {

   S& operator << ( int i ) { return *this; }

}


S& ::operator << ( S& s, int i ) { return s; }


f() {

   S s;

   s << (int) 5;        // ::op << or S::op<< ??

}


Where defined in the std?

Email responses appreciated.

Thanks,
--Michael
mcg@grok.berkeley.edu
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]