CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Threaded View

  1. #17
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: operator overloading

    Quote Originally Posted by laserlight View Post
    What is operator+ supposed to do? Why work with a temporary char* when you can work with a temporary FunnyString that is returned? Have you considered implementing operator+=, then possibly implementing operator+ by using operator+=?

    EDIT:

    Sounds possible, but I cannot find where dakotabk made the mistake of setting the data member variable to anything other than the result of new[] or a null pointer constant.
    He was going to change it to point to an empty string.

    As for operator+, it is to allow efficient implementation of this that the standard does not require that it internally holds a contiguous buffer. Effectively you can have a variation of a string that has two or more pointers concatenated together (A rope, I think they call it).

    It is relatively easy to implement a string that works. It is extremely difficult to implement one that works well in all (or at least the most common) situations.
    Last edited by NMTop40; May 20th, 2009 at 10:23 AM.

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

Featured