Skip to content

Instantly share code, notes, and snippets.

@earayu
Created May 3, 2023 14:43
Show Gist options
  • Save earayu/93f26c3af0c210ea1e4c79120119e67a to your computer and use it in GitHub Desktop.
Save earayu/93f26c3af0c210ea1e4c79120119e67a to your computer and use it in GitHub Desktop.
book notes
@earayu
Copy link
Author

earayu commented May 3, 2023

image
C++ standard lib is like libc, different hardware/system has different implementations. eg. MSVC、GNU libstc++、LLVM libc++.
Boost lib is like guava lib in Java.

@earayu
Copy link
Author

earayu commented May 3, 2023

Functions:
A function cannot be called unless it has been declared.
The semantics of argument passing are identical to the semantics of initialization (§3.4.1).

Need to understand how the argument is passed:
image

@earayu
Copy link
Author

earayu commented May 3, 2023

Types:
image

@earayu
Copy link
Author

earayu commented May 3, 2023

Interface + Header file:
interface should be defined in header files, implementation file and user code file should include the header file
image

@earayu
Copy link
Author

earayu commented May 4, 2023

Resource Management:
malloc/free不会掉用构造函数和析构函数;
new/delete、new[]/delete[]要成对出现,但是实际代码中很难保证正确性;
最好的办法是RAII原则,对象的生命周期和它的作用域保持一致。一些组件实现了RAII,比如shared_ptr.

@earayu
Copy link
Author

earayu commented May 4, 2023

class拥有的“特殊函数”,包括构造函数和操作符重载函数
image

@earayu
Copy link
Author

earayu commented May 5, 2023

template:
可以为template的类型参数设置一些限制条件,称为concept
image

@earayu
Copy link
Author

earayu commented May 5, 2023

template:
除了类型之外,value也能作为template的参数
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment