Jump to content

C++: Difference between revisions

122 bytes added ,  19 June 2022
Line 580: Line 580:
[https://github.com/rigtorp/awesome-modern-cpp List of resources]<br>
[https://github.com/rigtorp/awesome-modern-cpp List of resources]<br>
* Use RAII principles.
* Use RAII principles.
** I.e. each object should manage it's own memory rather than the caller having to manage it.
** You should never use `malloc` and `free` unless interfacing with C libraries.
* Use smart pointers instead of new and delete.
* Use smart pointers instead of new and delete.
** Namely, <code>std::make_unique</code> and <code>std::shared_ptr</code>.
** Namely, <code>std::unique_ptr</code>, <code>std::shared_ptr</code>, and <code>std::vector</code>.
** Or <code>std::vector<char></code> if you just need some memory in the heap.
* Use clang-format.
* Use clang-format.