Re: Problem of Pass by Reference in C++
From: Dan Cernat (dcernat_at_excite.com)
Date: 12/15/03
- Next message: jeffc: "Re: Private constructor"
- Previous message: Thomas Matthews: "Re: CRT, Member Initialisation, static data, constant data, global objects"
- In reply to: alan: "Problem of Pass by Reference in C++"
- Next in thread: jeffc: "Re: Problem of Pass by Reference in C++"
- Reply: jeffc: "Re: Problem of Pass by Reference in C++"
- Reply: jeffc: "Re: Problem of Pass by Reference in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Dec 2003 08:29:34 -0800
cheung_yuklun@i-cable.com (alan) wrote in message news:<7bd5ab13.0312150130.1759ee8e@posting.google.com>...
> Hi All,
>
> I have a problem on C++ pass by reference concept.
>
> I saw some funcions which is :
>
> e.g.
> int& func(int &a)
> {
> ....
> ..
> }
>
> I understand the use of "int &a",
> but I would like to know what is the use of "int&" ? and how to use it?
> any examples?
>
> Please help.
> Best regards,
> Alan
int &a;
and
int& a;
are exactly the same.
People prefer the first because is less confusing:
int &a, b; // declares a as reference to an int and b as int
int& a, b; // does the same but someone might think that b is also a
reference to an int
note that in example above I didn't initialised the references which
is an error.
/dan
- Next message: jeffc: "Re: Private constructor"
- Previous message: Thomas Matthews: "Re: CRT, Member Initialisation, static data, constant data, global objects"
- In reply to: alan: "Problem of Pass by Reference in C++"
- Next in thread: jeffc: "Re: Problem of Pass by Reference in C++"
- Reply: jeffc: "Re: Problem of Pass by Reference in C++"
- Reply: jeffc: "Re: Problem of Pass by Reference in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|