"&" is the bitwise operator when used in proper context.
"&" is reference operator when used in proper context.
"*" is a multiplication operator when used in proper context.
"*" is a de-referencing operator when used in proper context.
"&*" is a reference to a pointer type.
but how does the below program works with the * and &???
In the code below, the first line, which is a function declaration, the parameters are pointers, which is indicated with the * symbol.
By typing a * between the class and its instance-name, you create a pointer. A pointer simply enough points to a variable. So instead of having an int with it contents, you point to an other int, and if that other int changes, then you can read that through the pointer aswell. Pointers can be changed to point at something else, while references cant.
The second line we create a reference to our variables and send them into the function.
A reference means the actual path to whereever in the memory your integer (or other class) is located.
When defining a pointer, you give it a reference to whatever it must point to.
In this code, we have to put a * in front of the pointers. That is to dereference them. Because a pointer does not exactly equal what it is pointing to. If you printed x, y and z directly you would just get the "location-id" of the referenced item.
So putting the * in front of the pointer, dereferences them, so we get the content they are pointing to instead.
I hope you understand this.
Pointers and references are powerful and a large player in performance. It is very benefitable to learn how to use them, and... use them! :)
If you still are not sure, you are welcome to ask.
I am working creating a fully encapsulated, homogeneous singly linked data structure. The Listing class and SinglyLinkedList class that are part of the whole application compile fine, but the problem ...