-
passing paramaters
Anyone wanna explain to me the three ways of passing paramaters? I just started my C programming class, and we were talking about paramaters and I fell asleep cuz my teacher is an anus. Anyways...he said someting about values and reference and other stuff, and I have no idea what he's talking aboout. So, a brief explanation wouldn't hurt...thanks.
-
when you alter parameters passed by reference you alter the originally passed variable, when you alter parameters passed by value, you only alter a copy of the variable passed to the function. When you pass a pointer, you can alter the value to which the pointer points to, while the pointer itself is only a copy unless you pass it by reference.
-
I only know of 2 ways in C to pass parameters...
3 in C++, but only 2 in C and only 2 in theory.
-
yeah true, that makes C++ less abstract than C in this aspect.
-
No, only backwards compatible.
References are an abstraction of pointers, but pointers were kept, this is why there are 3 ways now.