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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started