Question
#include #include using namespace std; class Slacker :public Comparable{ string name; int classesMissed; public: Slacker(int missed, string n): classesMissed(missed), name(n) {} // they don't even
#include
class Slacker :public Comparable{ string name; int classesMissed; public: Slacker(int missed, string n): classesMissed(missed), name(n) {} // they don't even bother to validate their input! string toString() const { return name + " missed " + to_string(classesMissed) + " classes"; } };
class Workaholic:public Comparable { int workHours; // they don't have a name ... work is more important! public: Workaholic(int wh) { assert(wh > 12 && wh
};
class WorkFamilyBalanced:public Comparable { string name; int familyHours; int workHours; public: WorkFamilyBalanced(int fh, int wh, string n): name(n) { assert(fh >= 0 && wh >= 0); familyHours = fh; workHours = wh; } string toString() const { int diff = abs(workHours - familyHours);
return name + " spent " + to_string(workHours) + " hours at work" + " and " + to_string(familyHours) + " with family " + "(diff = " + to_string(diff) + ")"; }
};
//------------------------------------------------------------------------- void sort(Comparable * a[], int size) { for (int i = 0; i compareTo(*a[j+1]) == 1) swap(a[j], a[j+1]); }
bool all_same(Comparable * a[], int size) { for (int i = 0; i compareTo(*a[i+1]) != 0) return false; return true; } //-------------------------------------------------------------------------
int main() { cout
sort(a, 3); for (int i = 0; i (a[i])->toString()
if (all_same(a, 3)) cout
cout
sort(b, 3); for (int i = 0; i (b[i])->toString()
if (all_same(b, 3)) cout
cout
sort(c, 3); for (int i = 0; i (c[i])->toString()
if (all_same(c, 3)) cout
cout
sort(d, 4); cout
OBJECTS OF DIFFERENT "
return 0; }
Find the missing class and the functions for the Outlook to appear like the image in c++
Sorting 3 slackers (based on the number of classes missed). Tania missed 50 classes Josh missed 73 classes Jimmy missed 81 classes * Not all slackers are the same! * The slackers are sorted! Sorting 3 workaholics (based on their work time). Workaholic worked 23 hours non-stop! Workaholic worked 23 hours non-stop ! Workaholic worked 23 hours non-stop ! * All workaholics are the same! * The workaholics are sorted! Sorting 3 work-family-balanced objects (based on the absolute difference between work and family time). Fatima spent 12 hours at work and 7 with family (diff = 5) Salwa spent 8 hours at work and 9 with family (diff = Ahmad spent 8 hours at work and 8 with family (diff 0) * The balanced objects are not all the same! * The balanced objects are sorted! Attempting to sort objects of mixed classes. terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_castStep 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