3 ms·
Looking around the site, there's a free pdf chapter available via the publisher link (Chapter 12, Containers). https://ptgmedia.pearsoncmg.com/images/978013681
by photochemsyn 4y ago
Looking around the site, there's a free pdf chapter available via the publisher link (Chapter 12, Containers).
https://ptgmedia.pearsoncmg.com/images/9780136816485/samplepages/9780136816485_Sample.pdf https://ptgmedia.pearsoncmg.com/images/9780136816485/samplep...
It's worth comparing that to one of the more popular free C++ resources, learncpp:
https://www.learncpp.com/cpp-tutorial/container-classes/ https://www.learncpp.com/cpp-tutorial/container-classes/
The 'advice' section in the Tour excerpt is perhaps the most useful part. The learncpp excerpt is more about writing your own container class - note that many would consider the examples outdated with lots of raw new and deletes, but others would say, how else would you learn why uniq_ptr was introduced? (learncpp covers that later).
As far as how containers are allocated, C has malloc, calloc and free; new and delete in 'C with classes C++' are wrappers around those functions, and modern C++ has unique and shared pointers as wrappers around new and delete in turn. Actually learning modern C++ in depth thus seems to require going through that whole chain, including gaining a solid understanding of stack vs. heap, and the benefit is improved performance relative to languages like Python and JavaScript.
There's a notion that one can prototype in Python and then just translate that easily to modern C++, using idioms like ranges, without necessarily knowing the history of C++. It's an interesting idea, seems to be fairly popular, but I'd guess you'd still need to have that foundation in C to make it really work well.
- CamperBob2 4y agoThere's a notion that one can prototype in Python and then just translate that easily to modern C++ That was my first thought on looking at the github link posted by waynecochran above: if I'm going to write C++ code that looks like that, why don't I just use Python or a similar language? What exactly is C++ doing for Wayne here? It's not going to be much slower if it all, given that all he's doing is invoking higher-level abstractions. Another thought: again, given the abstractions and high-level resources that C++ programmers will be coming to rely on in the years ahead, someone could "just" write a back end that translates a cleaner high-level language like Python to modern C++ for compilation and optimization.
- pjmlp 4y agoPerformance, and not having two languages to worry about. Apparently that Python translator is still to happen, given how many keep using native libraries written in C, C++ and Fortran. And cython isn't that great, given that it requires manual tuning.