3 ms·
I don't know what you have planned for future installments, but I would make sure to emphasize that C++ more-or-less simply codifies common practice in C. E.g.
by colanderman 8y ago
I don't know what you have planned for future installments, but I would make sure to emphasize that C++ more-or-less simply codifies common practice in C. E.g. how std::vector just codifies the practice of dynamically sized arrays using realloc, and iterators just codify and generalize the use of pointers as indices. I was not a C++ convert until I realized this.
- ahubert 8y agohi colanderman, that is exactly the plan! I have a section on classes already done as something that most C projects eventually do by hand (ie, bunch of functions that accept a pointer to a struct as first parameter, which is actually "this"). You can even extend that into inheritance where you see most C based GUI toolkits emulating classes in all kinds of ways. Even the Linux kernel has tricks like this. Thanks for the tips!
- pjmlp 8y agoRegarding the standard library you might also give a brief explanation about bounds checking in debug builds for example.
- vardump 8y ago> how std::vector just codifies the practice of dynamically sized arrays using realloc I haven't ever seen std::vector using in-place realloc when resizing. The implementations I've seen simply always allocate a larger vector and copy the elements over. Realloc tries to expand already allocated memory region if there's enough space immediately after current block. New allocation and copy is only done when this is not possible.