[bt-devel] Refactoring displaywindows classes; a future feature
Eeli Kaikkonen
eekaikko at mail.student.oulu.fi
Fri Nov 20 01:39:11 MST 2009
On Thu, 19 Nov 2009, Gary Holmlund wrote:
> Another technique is to pass variables as a const reference (const
> QString& str). The code generated is just the passing of a pointer. It
> works for any class, not just Qt, and you have a guarantee that the
> called function cannot change anything about the variable. At my work we
> always use const reference for a variable we don't expect the called
> function to change and we only use a pointer if we are expecting a
> returned value in the variable.
Yes, remembering that if the argument has to be stored in the receiver
it has to be copied anyways or made into a pointer (is the latter
possible? (a semirhetorical question, doesn't need an answer:) ).
According to its nature C++ uses some words "overloaded" in meaning
which makes them hard to learn and understand. "const" is one of them.
We have had (and may still have) code like "void func(const int i);"
which doesn't usually make any sense. Also we don't use "void memfunc()
const;" too much even if it could ve very helpful.
But this was offtopic...
Yours,
Eeli Kaikkonen (Mr.), Oulu, Finland
e-mail: eekaikko at mailx.studentx.oulux.fix (with no x)
More information about the bt-devel
mailing list