0

I have an assignment that requires me to create an empty linked list key: LINKED_LIST [KEY], another linked list data_items_1: LINKED_LIST [DATA1] and a hash table data_items_2: HASH_TABLE [DATA2, KEY] in the constructor. The post condition that my professor put was

object_equality_for_keys: keys.object_comparison
object_equality_for_data_items_1: data_items_1.object_comparison
object_equality_for_data_items_2: data_items_2.object_comparison

When I run the program I get a contract violation. In the debugger it's always pointing to this line of code and I'm not sure why. What is the purpose of this post condition and how do I not violate this contract? Error Message

Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35

1 Answers1

0

The feature compare_objects of class CONTAINER indicates whether that container uses = (reference comparison) or ~ (value/object comparison, which calls is_equal internally) when comparing items. You can call compare_objects or compare_references to configure individual containers and ensure they work the way you need them to.

obnosim
  • 151
  • 3