---
# System prepended metadata

title: C++ 笔记

---

# C++ 笔记

> [TOC]

## Notes:
### Pylomorphism
- [Polymorphism in C++ - tutorialspoint](https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.htm)
- purpose: @ErBaiWu 
- static/early binding: @shasha 
    - bind/linkage 的概念不是 Class 和 object 之间的，而是 Class 和 member function之间的关系。
- dynanic/late binding: @shasha 
- virtual function: @ErBaiWu   
    - 有了virtual 代表该function可以被子类覆盖。
    - 没有virtual 则静态绑定。
    - 子类必须 overwrite 父类 pure virtual function

### Call C from C++
- [Using extern "C" - YouTube](https://www.youtube.com/watch?v=QNZWMw8wWhc&list=PLypxmOPCOkHXJqwYuIpLtG4mXxRJBacqx&index=10)
- ```bash
    vi addnum.c # define function addnum()
    gcc -c -Wall -Werror -fpic addnum.c # .c -> .o
    gcc -shared -o libaddnum.so addnum.o # .o -> .so
    vi addnum.h # declare function addnum
    vi foo.cpp # use addnum from .c using extern "C"
    g++ -o foo foo.cpp -L. -laddnum # compile foo using .so
    export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
    # OR
    g++ -o foo foo.cpp addnum.o
  ```
    

### Others
- Binary Operator Overriding: 自定义类型的二元操作符（+ - * /


## Open Questions:
- [ ] when will we be using private constructor/destructor? @ErBaiWu  
- [ ] do we have to make it `public` when we want to inherit from a baseClass? `Class ClassSub: public ClassSuper`




## References:
- [C++ Programming in Linux Tutorial - YouTube](https://www.youtube.com/playlist?list=PLypxmOPCOkHXJqwYuIpLtG4mXxRJBacqx)
- [C++ - Tutorialspoint](https://www.tutorialspoint.com/cplusplus/index.htm)


## Chat Zone

> [time=Mon, May 4, 2020 11:43 AM][color=#4f2cc1]
> 二百五何在？？
> 
---

> [name=Xiaosha Xing][color=#4f2cc1]
> 
> 😝
> [name=Jialiang]
>  
> 我是🐷



