Parameter passing in C++ can be one the easiest things to do, and can also be one of the most confusing aspects of the language. More than any other section in this tutorial, is is very important that you understand how passing works, in all its weird forms. Why? Well, your concepts of how a program runs and keeps track of variables are going to be greatly expanded, hopefully helping you write better code that you can really understand. Let's apply a fictional situation to the problems we'll be facing ahead. Imagine you've found the world's largest burrito in Costa Rica, weighing in at over 80 tons. You meet with a shipping company to get them to move the burrito to New York, where it can be sold. Unfortunately, it's much too heavy to just bring the burrito to their office, so you give them directions where they can find the burrito. Of course, the situation we speak of really is talking about passing huge amounts of data to a function. What if you wanted to pass a structure that you could barely fit in your computer's memory to another function? Just like in the above situation with the super-burrito, functions need a way of not being given these gigantic pieces of data. They need directions to the data. |