passing POD by value with const qualifiers. Silly or not?

Stefan Teleman stefan.teleman at gmail.com
Fri Feb 22 21:02:58 GMT 2008


On Fri, Feb 22, 2008 at 3:50 PM, Ingo Klöcker <kloecker at kde.org> wrote:

>  This is a pretty stupid example, but nevertheless it should illustrate
>  why it might be nice to put a const before a function argument:
>
>  void f( const int x )
>  {
>   if ( x = -1 ) {
>     return;
>   } else {
>     print( x );
>   }
>  }

if (-1 = x) {

// ...

And, thusly, you don't need const to avoid this one ... :-)

-- 
Stefan Teleman
KDE e.V.
stefan.teleman at gmail.com


More information about the kde-core-devel mailing list