Method overloading with const/non-const variants (was: Re: KDE/kdelibs/kdecore)
thiago at kde.org
Tue Jul 8 17:19:41 BST 2008
Richard Dale wrote:
>I think it is great that people can understand these rules, and manage
> to write code where they understand how it works. But personally I wish
> we didn't use const overloading in KDE libs unless absolutely
> necessary. There are no other languages apart from C++, that use const
> overloading as far as I know, and it makes it awkward for language
In case of const overloading, there should be a constFoo function that is
const only, so that you can access it from other languages too, as well
as making code clearer.
Anyways, you can always call the const function if you want by making your
object const too:
const Object *constFoo = foo;
const Object &constFoo = foo;
This can be done even in the binding.
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the kde-core-devel