Re: can someone explain to me, a C/Hw guy, what the diff is between a reference (&) and a pointer?
From: steve (_no_at_way.com)
Date: 09/16/04
- Next message: CoolPint: "Re: Help: How many explicit specializations required?"
- Previous message: Alex Vinokur: "Re: google "top coder" contest = stacked against C++ coders"
- In reply to: bo: "C++: can someone explain to me, a C/Hw guy, what the diff is between a reference (&) and a pointer?"
- Next in thread: Peter Koch Larsen: "Re: can someone explain to me, a C/Hw guy, what the diff is between a reference (&) and a pointer?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 16 Sep 2004 15:42:37 +0200
Added to what everyone else has said, it is also important to understand the
implication of ownership when deciding whether to use a reference or a
pointer.
Pointer are generally used to take ownership ( responsible for deleting it
if it was new'd ) of an object, whereas a reference would be use when
someone else has ownership of the object.
While you could implement the "ownership/non-ownership" using a pointer in
both cases, it does make the code self documenting, and lets the compiler
check for bugs :-)
HTH
-Steve
"bo" <bo@cephus.com> wrote in message
news:9q1jk01jqfp8rnri88udpdcmfqvp8clpgu@4ax.com...
> And why and where one should use one vs. the other?
>
> Verbally, it seems like semantics to me--but obviously there is some
> actual difference that makes references different and or preferable
> over pointers in some cases...
>
> TIA
>
- Next message: CoolPint: "Re: Help: How many explicit specializations required?"
- Previous message: Alex Vinokur: "Re: google "top coder" contest = stacked against C++ coders"
- In reply to: bo: "C++: can someone explain to me, a C/Hw guy, what the diff is between a reference (&) and a pointer?"
- Next in thread: Peter Koch Larsen: "Re: can someone explain to me, a C/Hw guy, what the diff is between a reference (&) and a pointer?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|