Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6786

Re: Use of const for non-reference parameters

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Use of const for non-reference parameters
Date Thu, 16 Jun 2011 21:15:49 +1200
Lines 15
Message-ID <95tvubFd2pU10@mid.individual.net> (permalink)
References <ygfhb7qi2dg.fsf@janus.isnogud.escape.de>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net fZRE/ZJqjSxp9yOa6XgpKgrsFN/nxe4enMSY+OxmLZXjNwrLS9
Cancel-Lock sha1:6FvRWKV6Zsi8qwPXBZgYckU0eCg=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <ygfhb7qi2dg.fsf@janus.isnogud.escape.de>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:6786

Show key headers only | View raw


On 06/16/11 08:53 PM, Urs Thuermann wrote:
> I'm working on a project that uses const for function parameters that
> are neither references nor pointers, i.e. something like this:
>
> 	int foo(const int a) { ... }
> 	int bar(const string b) { ... }
>
> I don't see why this is useful.  Since the argument is copied to the
> called function it doesn't matter to the caller whether the argument
> is modified or not.  So why would one want to write code like that?

It doesn't make a lot of sense.  Maybe they forgot the &?

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Use of const for non-reference parameters Urs Thuermann <urs@isnogud.escape.de> - 2011-06-16 10:53 +0200
  Re: Use of const for non-reference parameters Ian Collins <ian-news@hotmail.com> - 2011-06-16 21:15 +1200
    Re: Use of const for non-reference parameters yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-06-16 11:50 +0000
  Re: Use of const for non-reference parameters "Balog Pal" <pasa@lib.hu> - 2011-06-16 11:35 +0200
    Re: Use of const for non-reference parameters Urs Thuermann <urs@isnogud.escape.de> - 2011-06-16 15:21 +0200
      Re: Use of const for non-reference parameters Marc <marc.glisse@gmail.com> - 2011-06-16 16:25 +0000
  Re: Use of const for non-reference parameters Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-16 02:38 -0700
  Re: Use of const for non-reference parameters Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-16 03:15 -0700
  Re: Use of const for non-reference parameters "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2011-06-16 13:33 +0200
  Re: Use of const for non-reference parameters Howard Hinnant <howard.hinnant@gmail.com> - 2011-06-16 09:50 -0700
    Re: Use of const for non-reference parameters Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-16 13:22 -0700
      Re: Use of const for non-reference parameters Howard Hinnant <howard.hinnant@gmail.com> - 2011-06-16 13:49 -0700
        Re: Use of const for non-reference parameters Gerhard Fiedler <gelists@gmail.com> - 2011-06-17 11:41 -0300
          Re: Use of const for non-reference parameters "Balog Pal" <pasa@lib.hu> - 2011-06-17 18:40 +0200
            Re: Use of const for non-reference parameters "Thomas J. Gritzan" <phygon_antispam@gmx.de> - 2011-06-17 22:01 +0200
              Re: Use of const for non-reference parameters "Balog Pal" <pasa@lib.hu> - 2011-06-18 03:01 +0200
            Re: Use of const for non-reference parameters Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-17 13:30 -0700
          Re: Use of const for non-reference parameters Howard Hinnant <howard.hinnant@gmail.com> - 2011-06-17 16:51 -0700
  Re: Use of const for non-reference parameters "Johannes Schaub (litb)" <schaub.johannes@googlemail.com> - 2011-06-17 16:35 +0200
  Re: Use of const for non-reference parameters Juha Nieminen <nospam@thanks.invalid> - 2011-06-18 10:14 +0000
    Re: Use of const for non-reference parameters Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-18 11:45 +0000
      Re: Use of const for non-reference parameters "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-18 19:27 +0200

csiph-web