|
-
May 3rd, 2005, 01:06 PM
#1
Thread Starter
Lively Member
Is this bad?
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;
}
-
May 3rd, 2005, 04:31 PM
#2
Re: Is this bad?
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 3rd, 2005, 04:33 PM
#3
Thread Starter
Lively Member
Re: Is this bad?
Thanks... and it wasn't my code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|