I know what & how pointers and references are used. At least I thought
I did. I came across this code that explains Data slicing by
passing by value, see below. My question concerns the three functions
that are within the while statement below, I will put it here for easier reference.
I am confused as to what these functions are passing.
Here is my confusion. For example the valuefunction above accepts a pointer.
But why is it called valuefunction? Passing by value it should have been written as follows valuefunction(ptr) not valuefunction(*ptr). For the
ptrfunction(ptr) above why is it not ptrfunction(*ptr) and
reffunction(*ptr) should be reffunction(ptr).
Can someone explain why it is written in this manner?
> Here is my confusion. For example the valuefunction above accepts a pointer.
No, it does not.
See the declaration of the function, it accepts an object. void valuefunction(mammal);
> Can someone explain why it is written in this manner?
You seem to be confusing by the calls to the function.
If the function wants an object you must pass an object, the compiler will reject anything else.
There you've got a pointer. If you dereference a pointer (with operator *) you'll get an object, that's what you are passing to the fuction.