C++ Logo

sg20

Advanced search

Re: [isocpp-sg20] Education references for teaching data structures implementation in C++

From: Muneem <itfllow123_at_[hidden]>
Date: Mon, 1 Jun 2026 11:33:06 +0500
I wanna play the devil's advocate, and say that you aren't supposed to fit
textbooks in every single thing. Like here me out:
Textbooks are generally meant to be tailored to many types of people, and
when it comes to c++, no author would want a book that has a small scope,
since everyone wants some glory to there name. What I think you need is to
write some research manuscript style documents on what ever you want to
teach, with PowerPoint presentations corresponding to them, or use an
existing one. For example, I learned a few things here and there from this,
when I was 15, and was looking for a shortcut:
https://github.com/jzarnett/ece252/tree/master
I know that the other person also used references to books, but he has the
flexibility to update his information while still referencing the older
books for the key idea.

All of this boils down to:
"The C++ programming language 4th edition by Bjarne Stroustrup" for the
base reference of the core idea of the facilities provided by the language
and how to use them.
And any other old books that the emails before recommended.
The trick to using them while highlighting modren C++ features is to
reference them for core ideas and stuff, while using modren references
(even standard ones) for the practical stuff. The GitHub link of ece252
does it really well, and honestly made me very curious to look at the POSIX
API and systems programming.

Honestly I love the model of big well known authors chasing glory by
writing general books and others writing content for courses like ece252.
It's a beautiful balance in my opinion. I hope you also contribute to the
world and your students by doing the same, since we all want something that
outlives a lecture.



On Sun, 31 May 2026, 10:44 pm JOSE DANIEL GARCIA SANCHEZ via SG20, <
sg20_at_[hidden]> wrote:

> Given what I have discussed with my colleague. It is more the first thing.
> However, I think that many things can be improved. In many cases smart
> pointers would make an improvement. I have opinions on the approach I would
> like for this and many other things.
>
> In any case, the question is not how to teach the course. But what
> textbooks are there available and if we are aware of books doing this in a
> more modern way?
>
> Thanks for all the feedback I received so far.
>
> On Sun, May 31, 2026 at 7:13 PM Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
> wrote:
>
>> On Sun, May 24, 2026 at 3:35 PM JOSE DANIEL GARCIA SANCHEZ via SG20 <
>> sg20_at_[hidden]> wrote:
>>
>>>
>>> I have been asked by a colleague about good teaching references
>>> (preferrrably books) for teaching basic implementation of data structures
>>> in C++.
>>> Any recommendations?
>>>
>>
>> (Spoiler: I have no recommendations.)
>> FWIW, I think there's two ways to interpret this topic. Are you asking
>> for material on *learning data structures* that just happens to use C++
>> as the implementation language? Or are you asking for material on learning
>> how to *implement data structures in C++*?
>>
>> For "learning data structures," you'll end up using C++ as an "only
>> slightly better C" or a "weirder-looking Pascal." You can assume that the
>> payload type is something trivial like `int`, so you don't have to explain
>> the difference between "allocating space for an element" and "constructing
>> an element." You'll still use raw pointers, because after all the point of
>> the class is to teach how to implement data structures — you can't teach
>> linked lists without pointers, or splay trees without pointers. You won't
>> care about the C++ allocator model. You might care about C++ destructors,
>> in that you do want to teach how to tear down a data structure and free its
>> memory properly after the fact, and (with C++ as the implementation
>> language) the idiomatic way to spell that is with a "~". (Whereas in C
>> you'd just write a function named `linkedlist_free` or whatever.)
>>
>> I can see how a book from the '90s or '00s that used C++ as its
>> implementation language would have deficiencies from a modern programmer's
>> point of view. Small ones, but annoying ones that the instructor would have
>> to patch "by hand" and that would be icky. For example, your SplayTree
>> class should `=delete` its special members, instead of making-them-private
>> or doing-nothing-about-them. For example, if there's anyplace that returns
>> a class type, it should just return it by value, rather than by
>> out-parameter as most '90s textbooks would have done. Etc.
>>
>>
>> For "learning *C++ implementation of* data structures (e.g. STL
>> containers)," you'd care to focus much more on:
>> - Template programming. Making your container a class template.
>> Documenting requirements on T.
>> - The difference between *allocating* memory, versus *constructing* a
>> payload.
>> - The C++ allocator model.
>> - The iterator model. Providing const and reverse iterators.
>> - The proper idiom for making iterator convertible to const_iterator but
>> not vice versa.
>> - Copy construction and assignment.
>> - Move semantics.
>> - That `size()` must be O(1), or omitted.
>> - Specific non-STL idioms for non-STL-style containers such as tries and
>> slot-maps.
>> - Proxy references.
>> etc. etc.
>> Which is a vastly different question, and also vastly more difficult
>> material to collect and organize.
>>
>> –Arthur
>>
> --
> SG20 mailing list
> SG20_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg20
>

Received on 2026-06-01 06:33:23