Back to Basics: Pointers and Memory - Ben Saks - CppCon 2020

Опубликовано: 12 Ноябрь 2024
на канале: CppCon
42,148
1k

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---

The prevailing wisdom in Modern C++ is to favor smart pointers and container classes over raw pointers and built-in arrays -- there are too many traps and pitfalls that come with using those more-primitive types. However, many C++ programmers can’t avoid using them because they’re still so prevalent in legacy C++ code and C libraries. If you have to use raw pointers and built-in arrays, then you should learn to use them safely and effectively.

This session explains the true nature of built-in pointers and arrays, and why they’re so easily confused despite actually being distinct types. It covers the rules for pointer and array type conversions, along with the mechanics of pointer arithmetic and array subscripting. It compares and contrasts pointers with references and iterators, as well as the pointer and reference member types in the STL, to help you make more informed choices about what to use when. This session also explains the origins of the types size_t and ptrdiff_t, and their relationship to size and difference types in the STL.

You’ll leave with a clearer understanding of how pointer operations behave, whether you’re using raw pointers and built-in arrays or smart pointers and container classes.

---
Ben Saks
Chief Engineer, Saks & Associates

---
Streamed & Edited by Digital Medium Ltd - events.digital-medium.co.uk
[email protected]

*-----*
Register Now For CppCon 2022: https://cppcon.org/registration/
*-----*