[openbeos] Re: Pointer or reference?

  • From: Michael Phipps <mphipps1@xxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sat, 27 Mar 2004 12:01:11 -0500

I will speak only of my personal preference. :-)

I vastly prefer references. 
I use pointers when:
1) I need nullability (or anytime null is an option)
2) When I am using the pointer to become part of something else. Example:
foo::initialize(int *c) {
        intPtr=c;
}




On 2004-03-26 at 09:10:06 [-0500], Waldemar Kornewald wrote:
> Hi,
> this is a code-style question:
> When should I use a pointer as a parameter and when should I use a 
reference? 
> Is the general convention that a pointer indicates that the passed 
> information will be modified? But the BMessage in MessageReceived() is a 
> pointer although it is not intended to be modified by the receiver.
> 
> Bye,
> Waldemar

Other related posts: