Pass by ref vs Pass by value

Here is my understanding of pointers, please feel free to correct me if I am wrong at any point.
-As Ben said, you declare them with *
-Other operators include -> (which to my understand dereferences a pointer to a function in a class or struct- maybe it does more)
-There also is a something called the address of operator (&) this operator essentially gives you the memory location of a variable.

So way I understand it is again like Ben said, so you don’t keep copying things around in memory because then the program will grow monolithic in size and go out of control. Other languages use garbage collection to handle this. Essentially not passing variables is pass by value whereas passing a pointer to a variable is pass by reference. If I saw a function like doSomethin(int *thing1); if I wanted to pass one of my variables by reference to the function I would do so using the address of operator:
int localvar = 1;

Privacy & Terms