Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: What's the ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 30 of 30 Topic 9763 of 9909
Post > Topic >>

Re: What's the point of passing parameter by value (vs. const ref)

by "Matthias Hofmann" <hofmann@[EMAIL PROTECTED] > Jul 24, 2008 at 01:58 PM

"Jim Langston" <tazmaster@[EMAIL PROTECTED]
> schrieb im Newsbeitrag
news:WLOak.760$gz3.36@[EMAIL PROTECTED]
> 2. Passing a paramater by value allows modification of the paramater as
a
> local variable  I.E.
>
> void Reverse( const char* CString, int length )
> {
>    while ( --length )
>    {
>       std::cout << CString[length];
>    }
> }

I know that this does not relate to the original question, but there's an
off-by-one error in your code. The first letter of the original string
will
not be displayed, i.e. "Hello" turns to "olle" rather than "olleH". You
probably meant this:

void Reverse( const char* CString, int length )
{
     while ( length-- )
     {
        std::cout << CString[length - 1];
     }
}

-- 
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com
- The Creators of Toilet Tycoon
http://www.anvil-soft.de
- Die Macher des Klomanagers


      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 30 Posts in Topic:
What's the point of passing parameter by value (vs. const ref)
"Martin T." <  2008-07-02 11:58:01 
Re: What's the point of passing parameter by value (vs. const re
"Jim Langston"   2008-07-03 02:27:25 
Re: What's the point of passing parameter by value (vs. const re
Eric Johnson <eric.eer  2008-07-03 02:28:17 
Re: What's the point of passing parameter by value (vs. const re
"Hakusa@[EMAIL PROTE  2008-07-03 02:33:08 
Re: What's the point of passing parameter by value (vs. const re
mtlung@[EMAIL PROTECTED]   2008-07-03 03:28:03 
Re: What's the point of passing parameter by value (vs. const re
werasm <werasm@[EMAIL   2008-07-03 03:28:02 
Re: What's the point of passing parameter by value (vs. const re
=?UTF-8?B?RXJpayBXaWtzdHL  2008-07-03 03:28:01 
Re: What's the point of passing parameter by value (vs. const re
Le Chaud Lapin <jaibud  2008-07-03 03:28:02 
Re: What's the point of passing parameter by value (vs. const re
red floyd <redfloyd@[E  2008-07-03 03:28:02 
Re: What's the point of passing parameter by value (vs. const re
Pavel Minaev <int19h@[  2008-07-03 03:28:03 
Re: What's the point of passing parameter by value (vs. const re
Marcin.Barczynski@[EMAIL   2008-07-03 08:51:53 
Re: What's the point of passing parameter by value (vs. const re
Francis Glassborow <fr  2008-07-03 08:56:04 
Re: What's the point of passing parameter by value (vs. const re
Michael DOUBEZ <michae  2008-07-03 08:52:44 
Re: What's the point of passing parameter by value (vs. const re
"Andrew Koenig"  2008-07-03 09:58:01 
Re: What's the point of passing parameter by value (vs. const re
JohnMcG <JohnMcG@[EMAI  2008-07-03 15:45:38 
Re: What's the point of passing parameter by value (vs. const re
Mathias Gaunard <loufo  2008-07-03 15:47:07 
Re: What's the point of passing parameter by value (vs. const re
Deane Yang <deane.yang  2008-07-03 15:45:13 
Re: What's the point of passing parameter by value (vs. const re
"Jacky Goyon" &  2008-07-04 19:25:39 
Re: What's the point of passing parameter by value (vs. const re
"Martin T." <  2008-07-05 03:58:01 
Re: What's the point of passing parameter by value (vs. const re
Martin Bonner <martinf  2008-07-05 04:58:04 
Re: What's the point of passing parameter by value (vs. const re
David Abrahams <dave@[  2008-07-06 16:33:35 
Re: What's the point of passing parameter by value (vs. const re
LR <lruss@[EMAIL PROTE  2008-07-07 06:21:25 
Re: What's the point of passing parameter by value (vs. const re
Jorgen Grahn <grahn+nn  2008-07-07 17:36:35 
Re: What's the point of passing parameter by value (vs. const re
David Abrahams <dave@[  2008-07-07 17:57:14 
Re: What's the point of passing parameter by value (vs. const re
Le Chaud Lapin <jaibud  2008-07-08 15:23:54 
Re: What's the point of passing parameter by value (vs. const re
Tony Delroy <tony_in_d  2008-07-08 20:28:28 
Re: What's the point of passing parameter by value (vs. const re
Jorgen Grahn <grahn+nn  2008-07-19 14:37:18 
Re: What's the point of passing parameter by value (vs. const re
Jorgen Grahn <grahn+nn  2008-07-19 14:37:00 
Re: What's the point of passing parameter by value (vs. const re
Tony Delroy <tony_in_d  2008-07-22 15:28:24 
Re: What's the point of passing parameter by value (vs. const re
"Matthias Hofmann&qu  2008-07-24 13:58:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 13:15:37 CDT 2008.