i have designed two functions like
void verify(Hvrbuffer *message)--> this will be work when message is null or not null
void verify(Hvrbuffer &message)--> this will work only when message is not null
Can you please explain me in the above cases when i have to use pointer and references as function arguments other than the above mentioned scenarios
interms of memory allocation / deallocation and any other value added services for each one of these ?
thanks in advance,
In either case, memory for an object of type is not allocated Hvrbuffer is not allocated or deallocated when this function is called. Passing a pointer or a reference to an object does not create a copy of the object - they are equally efficient.
The only issue in question is: will the function always be called with a valid object? If yes, use a reference. If no, use a pointer (the pointer could be null).