Question: C++ pleaese helps file Sortable.h . It contains an abstract data type called Sortable which will act as a base class for any object a

C++ pleaese helps

file Sortable.h. It contains an abstract data type called Sortable which will act as a base class for any object a collection of which can be sorted. It has two virtual methods, compare and print. The compare method tells the object how to compare itself with another object. It returns true if the object it is being called from is smaller than the other object. The print method allows the object to display itself.

Modify your Data class so that it operates on Sortable objects instead of int objects. Recall from the textbook that we can not allocate abstract data types. Therefore, in order to accomplish the task in this exercise, you will need to use pointers.

Also, you are not provided with any .cpp files in order to test your code. Testing your code will involve creating a class that extends Sortable and pushing some objects of that class into your Data object and trying to sort and print them. This is the goal of the next exercise.

#ifndef LA6_Sortable_h #define LA6_Sortable_h class Sortable { public: virtual bool compare (const Sortable * s) = 0; virtual void print () = 0; }; #endif 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!