We talked about passing by reference and by value a little bit last time, but there's still plenty of important stuff to cover. We'll start with a brief refresher on the basics. There are two possible reasons to pass by reference. 1) If you want to use a function to edit a variable (instead of editing a copy). 2) For large objects where making a copy wastes too much time and memory. This first .cpp file covers reason (1).
This second .cpp file covers reason (2)
We're going to write a (short) library of functions. I have 3 goals for this segment of the lecture. 1) Learn how to create our own .h and .cpp files (similar to the ones we've been using from Mike), 2) Talk about testing our code as we write it, and 3) general practice with writing functions.
Problem statement: Oh no! For some unexplained reason we forgot how to use some of the standard string functions (specifically, substr, find, and erase). So now we have to write our own from scratch. We'll build myStringLib.h and myStringLib.cpp, then #include those into a main.cpp and use them there. Our makeshift string library will include 3 functions