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


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

Re: const and non const parameter passing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.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: const and non const parameter passing
Date Thu, 17 Nov 2011 23:24:43 +1300
Lines 25
Message-ID <9ik5nbFsoiU1@mid.individual.net> (permalink)
References <33539597.678.1321525054013.JavaMail.geo-discussion-forums@prou19>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net oI5lpwKv9xDQO6Vf1P/6CA8+9szy8Em2UsGkjxrsg07XQOs01z
Cancel-Lock sha1:kOf5vB9nhTLxDJx3fCFW1m/3b+0=
User-Agent Mozilla/5.0 (X11; SunOS i86pc; rv:6.0.2) Gecko/20111003 Thunderbird/6.0.2
In-Reply-To <33539597.678.1321525054013.JavaMail.geo-discussion-forums@prou19>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:11559

Show key headers only | View raw


On 11/17/11 11:17 PM, asit wrote:
> why the following code does not compile at line 14
>
> #include<iostream>
> #include<cstdlib>
>
> using namespace std;
>
> struct One
> {
>          void funct1()
>          {
>                  cout<<"Testing..."<<endl;
>          }
> };
>
> void funct2( const One&  c) //line 14
> {
>          c.funct1();

It will fail here. funct1() is a non-const member function, c is a const 
object.

-- 
Ian Collins

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


Thread

const and non const parameter passing asit <lipun4u@gmail.com> - 2011-11-17 02:17 -0800
  Re: const and non const parameter passing Ian Collins <ian-news@hotmail.com> - 2011-11-17 23:24 +1300
  Re: const and non const parameter passing asit <lipun4u@gmail.com> - 2011-11-17 02:20 -0800
  Re: const and non const parameter passing Juha Nieminen <nospam@thanks.invalid> - 2011-11-17 17:09 +0000

csiph-web