On Thu, Sep 14, 2006 at 10:28:39AM +0200, Georg Baum wrote: > > struct A { }; > > void operator+=(A &, int) {} > > int main() { A a; a += 1; } > > > > should compile just fine. > > Then you can explain to me why operator+= is a class member of std:string? I > don't want to add an out-of-class opertaor+= without knowing why the > existing ones are members.
Because in-class is working as well and the prefered style. However, the out-of-class version is there for exactly ou purpose: when the class itself cannot/should not be modified. Andre'