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


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

Re: Question on Basic Function Syntax

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Bo Persson <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: Question on Basic Function Syntax
Date Mon, 09 Apr 2012 14:22:30 +0200
Lines 26
Message-ID <9ug2k4Fav9U1@mid.individual.net> (permalink)
References <d8d21a09-f8b8-4644-8967-8095ee1c6eca@f27g2000yqc.googlegroups.com> <e0dfbedf-9308-48b4-ac89-3ce8d63497a1@h12g2000yqi.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net xE1bAnxrlU7dgW+JDm8UXwd5U4UwJ3UJYoOu1yPp+Kr6GZUxz1
Cancel-Lock sha1:+xoXW4xXpqtmDJShr+5dvgFg3vY=
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
In-Reply-To <e0dfbedf-9308-48b4-ac89-3ce8d63497a1@h12g2000yqi.googlegroups.com>
Xref csiph.com comp.lang.c++:15257

Show key headers only | View raw


Paul N skrev 2012-04-08 21:42:
> On Apr 8, 8:40 pm, Danny Gratzer<danny.grat...@gmail.com>  wrote:
>> Hello,
>> I have been reading my way through C++ Primer and I noticed that the
>> function prototype for one of the functions resembled this
>>
>> class A{
>>
>> public:
>>            void f(const int&  a) const;
>> ...
>>
>> };
>>
>> what is the purpose of that second const following f's parameters?
>>
>> thanks in advance.
>
> It means that calling the function doesn't alter the object that it is
> called on.

Which also allows you to call the function for constant objects.


Bo Persson

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


Thread

Question on Basic Function Syntax Danny Gratzer <danny.gratzer@gmail.com> - 2012-04-08 12:40 -0700
  Re: Question on Basic Function Syntax Paul N <gw7rib@aol.com> - 2012-04-08 12:42 -0700
    "f() const;", defined inside a struct ( i.e. a "class" ).  @Jeff-Relf.Me - 2012-04-08 12:56 -0700
      Re: "f() const;", defined inside a struct ( i.e. a "class" ).  danny.gratzer@gmail.com - 2012-04-08 13:11 -0700
        Re: "f() const;", defined inside a struct ( i.e. a "class" ).  Rui Maciel <rui.maciel@gmail.com> - 2012-04-08 22:22 +0100
      Re: "f() const;", defined inside a struct ( i.e. a "class" ).  danny.gratzer@gmail.com - 2012-04-08 13:04 -0700
        Re: "f() const;", defined inside a struct ( i.e. a "class" ).  Victor Bazarov <v.bazarov@comcast.invalid> - 2012-04-08 16:46 -0400
          Re: "f() const;", defined inside a struct ( i.e. a "class" ).  Marc <marc.glisse@gmail.com> - 2012-04-08 21:03 +0000
          Re: "f() const;", defined inside a struct ( i.e. a "class" ).  "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-08 23:35 +0200
      Re: "f() const;", defined inside a struct ( i.e. a "class" ).  nick_keighley_nospam@hotmail.com - 2012-04-10 04:05 -0700
    Re: Question on Basic Function Syntax Juha Nieminen <nospam@thanks.invalid> - 2012-04-09 08:03 +0000
      Re: Question on Basic Function Syntax Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-04-10 14:12 +0000
        Re: Question on Basic Function Syntax Juha Nieminen <nospam@thanks.invalid> - 2012-04-10 14:30 +0000
          Re: Question on Basic Function Syntax Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-04-10 21:57 +0000
    Re: Question on Basic Function Syntax Bo Persson <bop@gmb.dk> - 2012-04-09 14:22 +0200

csiph-web