OUString is mutable?

Noel Grandin noel at peralex.com
Fri Sep 28 06:58:32 PDT 2012


On 2012-09-28 15:55, Norbert Thiebaud wrote:
> On Fri, Sep 28, 2012 at 7:17 AM, Noel Grandin <noel at peralex.com> wrote:
>> That is exactly what makes it weird - it looks like a Java String, but it's
>> not, because you can do this:
>>
>>      void f(OUString s) {
>>           s = "2";
>>      }
>>
>>      OUString s = "1";
>>      f(s);
>>      cout << s; // will print "2"
>>
>> ie. the modification inside the method is visible outside the method.
> Really ? it does that ?
> Whoaa, that is unexpected, and way wrong. That should be considered
> 'entrapment' :-/
>
> Norbert
>
>

Sorry, that example code should read (note that the parameter is now a 
reference param)

     void f(OUString & s) {
          s = "2";
     }

     OUString s = "1";
     f(s);
     cout << s; // will print "2"



Disclaimer: http://www.peralex.com/disclaimer.html




More information about the LibreOffice mailing list