CSCI 41 Week 2 Day Day 2 - RAII
Today we talked about the rule of thumb for passing parameters to functions:
1) Call by value for primitives (int, float, double)
2) Call by const reference for objects (unless you need to change it, in which case you use just call by reference)
We talked a bit about static, which allows you to make global variables limited to a scope, or to make a variable attached to a class instead of to objects of that class. I gave some examples of variable shadowing (where you have variables with the same name in different scopes)
Finally, we got to talk about RAII, an acronym that means that you should acquire resources (such as new-ing memory) in your constructor and release resources (such as calling delete) in your destructor. A destructor is a function that is called when the variable goes away. I made a simple example of a Vector class to demonstrate this.