Hi,

I am having difficulty choosing between whether to pass an object by reference or to pass a pointer to it to a function. This is a generic question, not related to any particular class. Basically, if you want a function ro receive the address of an object, which option is preferable ?

I'm aware of a few considerations :

1 A pointer can have a null value. If the function declares a pointer parameter, the caller can pass in a NULL, and the function can test for it; with a reference parameter, the caller must specify an object.

2 If the function returns a pointer, it can return NULL, and the caller can test for it, with a reference return, the function must return an object.

3 One advantage of using a reference is that you won't be passed a NULL pointer. And so there’s no need to test for one.

4 Another advantage would be in easier coding of the called function, i.e. you don't have to dereference the pointer.

Regards,

Brendan