C++ Logo

sg20

Advanced search

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

From: JOSE DANIEL GARCIA SANCHEZ <jdgarcia_at_[hidden]>
Date: Mon, 1 Jun 2026 10:07:43 +0200
On Mon, Jun 1, 2026 at 8:33 AM Muneem via SG20 <sg20_at_[hidden]>
wrote:

> I wanna play the devil's advocate, and say that you aren't supposed to fit
> textbooks in every single thing.
>

Sure. 100% agreed. I never suggested that.

But some students need to complement other sources with textbooks for some
part of the course.


> 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
>

Thanks for the suggestion. In my courses I do that and more than that. And
of course, all my materials are distributed under Creative Common license.

I have been asking for somebody else who is trying to assemble something.


> 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.
>

We have many good references about the programming language. While the one
you mention is a great book, I tend to think that "Programmings principles
and practice: Using C++ 3rd edition" is much more useful for teaching
purposes.


> 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.
>

Each instructor needs to find their own model. There are many forces to be
considered: institutional rules, national regulations, background of
students, cultural aspects, ...


>
> 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.
>

Thanks! Recall that my question is not about how to teach, how to
organize teaching, which teaching model to use or any other aspect.

It is mostly about good support material (in the form of books or similar
persistent sources) for teaching data structures implementation while not
promoting old C++ practices that we do not want to encourage.

>From what I have seen so far, from the group's feedback (and my own
research), I have concluded that what my colleague (and I) are looking for
(with a focus on undergraduate students with solid foundational theoretical
basis) simply does not exist.

I will consider in the future, if such a thing is needed and if somebody
should write it.

See some of you next week in Brno!
--
J. Daniel García
>
>
>
> 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
>>
> --
> SG20 mailing list
> SG20_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg20
>

Received on 2026-06-01 08:08:25