Lecture 02
- 在main()之前声明function。
- Default parameters
参数可以设置默认值。
带默认值的参数必须放在参数表的最后。 - Value semantics:In java and C++, when variables (int, double) are passed as parameters, their values are copied.
-Modifying a parameter will affect the variable passed in. - Reference semantics: If you declare a parameter with an & after its type, it will link the functions to the same place in memory.
-Modifying a parameter will affect the variable passed in. 引用必须是有内存的地址,不能引用值。C++只会传递copy,除非引用 - Output parameters: (they don’t have to have values, just providing
space to store the output values.) - Procedural decomp.
- Strings, can be changed.
- Character
Lecture 03
Vectors (list)
#include "vector.h"
- vector (aka list): a collection of elements with 0-based indexes
-like a dynamically-resizing array (Java ArrayList or Python list)
// initialize a vector containing 5 integers
Vector<