Tuesday 24 October 2023

Chapter 27 // Exercise 4, 5 - Principles & Practice Using C++

In this exercise I'm using Visual Studio 2022.

Chapter 27 // Exercise 4

If you didn't already, write a C++ version of the intrusive List example in section 27.9 and test it using every function.

This took me a good hour. I still hate linked lists. For this one I decided to make the list templated instead of Name storing a linked list. All the functions are now part of the list and I considered having it use a std::unique_ptr but in the end decided to just go with new and delete as the whole point of an intrusive list is to be as efficient as possible.

Chapter 27 // Exercise 5

Compare results of exercises 3 and 4.

Github: N/A

I think it's obvious that I much prefer exercise 4. I don't like having all the functions on their own, the classes aren't managing their own memory and the syntax to create new ones of different types is just hideous. 

No comments:

Post a Comment