Results 1 to 3 of 3

Thread: Is this bad?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    82

    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;
    
    }

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    82

    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
  •  



Click Here to Expand Forum to Full Width