Re: The use of CONST and '&' as argument parameter
- From: "Mark" <swozz_@xxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 11:58:54 -0000
// call by value
void function1 (int para1)
{
para1 = 2; // modifies local copy of para1 (and not the variable
passed as para1)
}
// call by reference
void function2 (int& para1)
{
para1 = 2; // modifies the variable referenced by para1 ie x
}
void function3 (const int para1)
{
para1 = 2; // illegal - can't modify a const parameter
}
int x = 100;
function1 (x); // x still equals 100
function2 (x); // x = 2
------------------
--
Best regards
Mark
"Jack" <jl@xxxxxxxxxx> wrote in message
news:e4lgSt06FHA.1276@xxxxxxxxxxxxxxxxxxxxxxx
> In the case, which is better use
> void function1 (CONST int para1);
> or
> void function1 (int& para1);
> are they equvilent? (can't spell sorry)
> Thanks
> Jack
>
.
- Follow-Ups:
- References:
- Prev by Date: const and call by value parameters
- Next by Date: Re: The use of CONST and '&' as argument parameter
- Previous by thread: Re: The use of CONST and '&' as argument parameter
- Next by thread: Re: The use of CONST and '&' as argument parameter
- Index(es):
Relevant Pages
|