qt-interest@trolltech.com
[Top] [All Lists]

Re: I don't understand this error

Subject: Re: I don't understand this error
From: Matthieu Brucher
Date: Mon, 27 Feb 2006 16:10:41 +0100
Daniel Walz wrote:
Sorry, I'll never learn not to cut'n'paste links without screwing anything...

And a question, slightly off-topic, regarding first() in 4.x:
The documentation says there are two functions like:
T & first ()
const T & first () const

How will the compiler destinguish between these two? As I learned the functions are looked up by their arguments but never by their return type. Is this actually working as one would expect?

Regards,
Daniel

It depends of the context. If you use your reference in a const expression or if you use it with a const member - list.first().constmember() -, the second one is used. That's why you should always put a const if your member is not changed, in order to have a better optimization.

Matthieu

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>