LEC 1
1. Printf 在C++中的写法
2. Header file
1. 不能写 “.h”
2. strlen变成.size()
3. Namespace
前面用了“using namespace std;” 后面就可以直接写cout 不用写std::cout了
4. Input
就是input是std::cin >>
LEC 2
1. Classes
2. 3 access modifiers in C++
3. Getters & Setters
1. Generally we don’t want to expose internal variables to the outside world, so we keep them private and define getters and setters
We do not actually want to expose getters and setters either, except for cases (like here), where we are using the class directly for data storage
4. Split between .h and .cpp
5. Constructors and Destructors
6. Adding a constructor and destructor
7. Member Initialisation
A list of initialisations is inserted before the constructor body
在函数创造前,先列一个一个声明列表
Inheritence 继承
1. 和java的区别
Difference: There are no interfaces though 没有接口
Difference: C++ has access modifiers on inheritance 访问修饰符(public private protected)
2. Slicing
#
3. 转换 父类用子类的方法
4. The three ways to pass objects to functions
In C++ you can pass objects to functions in 3 ways (the first 2 are also in C and I assume you have seen them – still I will show examples):
1. Directly (Like with C structures – the objects are copied)
2. Pass a pointer (no copies are made)
3. Pass by reference
Pass by reference is a simplification of pass by pointer approach
1. The reference can’t be reassigned by the receiving method
2. The syntax looks nicer because it uses the dot notation
3. Effectively you are passing a pointer to an object
4. Therefore, the original object is NOT copied
5. Its content can be changed by the method and therefore any other pointers to the same object will see the changed version
Example :
Permanent objects: