I've heard doing stuff like this with the STL is bad... can any one explain why?
Code:string &operator += ( string & st, const int & i ) {
std::stringstream s;
s << st << i;
st = s.str( );
return st;
}
Printable View
I've heard doing stuff like this with the STL is bad... can any one explain why?
Code:string &operator += ( string & st, const int & i ) {
std::stringstream s;
s << st << i;
st = s.str( );
return st;
}
You mean overloading operators for the STL containers?
That's bad, but it's nothing to do with the STL. What's bad is that you modify the behaviour of something that doesn't belong to you. Well, there are libraries that do that, but they do it in very specific ways and it's their whole purpose.
What's also bad is that you pass the int by reference, as that's a waste. But that's beside the point.
Thanks... and it wasn't my code. :p