In this exercise I am using Visual Studio 2019 and a modified version of the std_lib_facilities header found here.
Chapter 21 // Exercise 6
In the Fruit example in section 21.6.5, we copy Fruits into the set. What if we didn't want to copy the Fruits? We could have a set<Fruit*> instead. However, to do that, we'd have to define a comparison operation for that set. Implement the Fruit example using a set<Fruit*, Fruit_comparison>. Discuss the differences between the two implementations.
This one was pretty simple, just had to change a few &'s to * in places. Set's don't clean up pointers either so you have to make sure that you're cleaning up the set after use which is easily forgotten...unless you use smart pointers.
No comments:
Post a Comment