[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: strings and QStrings
From:       David van Hoose <david-vh () home ! com>
Date:       2000-12-10 8:41:49
[Download RAW message or body]

Bo Thorsen wrote:
> 
> On Sun, 10 Dec 2000, David van Hoose wrote:
> 
> > Bo Thorsen wrote:
> > >
> > > On Sat, 9 Dec 2000, Guillaume Laurent wrote:
> > >
> > > > On Friday 08 December 2000 21:39, robbie wrote:
> > > >
> > > > > Thanks for the help I used
> > > > >
> > > > > QString defdrive=get_default_drive().c_str();
> > > >
> > > > For what it's worth,
> > > >
> > > > QString defdrive(get_default_drive().c_str());
> > > >
> > > > is a bit more efficient.
> > >
> > > No it's not. You should write a bug report if the compiler doesn't do this
> > > implicitly. So which of the two you use in your code doesn't matter; the
> > > compiled code is the same. Personally I find the "=" version more readable.
> >
> > The code for the operator should *NOT* implicitly be defined as a
> > constructor
> > as there may be other operations to be executed or not be.
> 
SNIP
> 
> This prints out "constructor" twice. It has no effects to change
> optimization levels or not optimize or debug or whatever. So, I repeat
> what I said: "Class c = object" will always call the copy constructor and
> not first call constructor and then operator=.

I know what it prints. A function that returns the object calls the copy
constructor.
It has nothing to do with the = operator at all. In that instance in the
copy, the
constructor should be a better choice as the = operator's extra
functionality is
unused.

-- 
-Dave
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic