STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 20RQE
Program Plan Intro

Algorithm:

  • Start a program.
  • Declare a class named “Sorter”.
    • Declare a required member variables and pure virtual function.
    • In public, define the member function “set_Array()”.
      • Inside the function set the array and size of an array.
    • Define the “sort” function.
      • Inside the function, call the “sort()” function with an argument size.
  • Define the “sort” function.
    • If the size is less than 1, the condition will ended.
    • Find the position of largest value in array and put it at the end of the array.
      • Use the “compare ()” function for sorting the given array.
      • Swap a pair of array elements.
      • Decrement the size by 1.
  • Define the derived class “Incr_Sorter” from the class “Sorter”.
    • In private, define the pure virtual function “compare()”.
      • If the “x” value is greater than “y” value return true.
  • Define the derived class “Decr_Sorter” from the class “Sorter”.
    • In private, define the pure virtual function “compare()”.
      • If the “x” value is less than “y” value return true.
  • Inside the “main” function,
    • Create the objects for the classes.
    • Declare and initialize an array of 5 values.
    • Call the “Incr_Sorter” function.
    • Call the “print_Array()” function for displaying the output.
    • Call the “Decr_Sorter” function.
    • Call the “print_Array()” function for displaying the output.
  • Define the “print_Array()” function.
    • Display the array.

Blurred answer
Students have asked these similar questions
write a c++ program
in c++: Implement the Array class that is defined below and test it in the main program. The main program must test all the member functions including the overloaded operators that are defined in the class:   #ifndef array_h #define array_h #include <iostream> using namespace std; class Array { // Class declaration        friend const Array operator+(const Array & a1, const Array &a2);        friend bool operator==(const Array & a, const Array &b);//Equality test public:        Array(int = 10); //Initialize the array with 0 values, default size =10        Array(const Array & a); // copy constructor        ~Array();//Destructor        int getSize();// return the size of the array.        const Array & operator=(const Array & a);//assignement operator        Array operator+(int x);//+ operator        bool operator!=(const Array & a) const;//Not equal test        void read();        void print();        Array operator-();//Negate (unary operation)…
Computer Science Write in Javascript please and use high order functions liek map or filter or reduce let obj = [ { mode: "hot" }, { temp: "low" }, { mode: "cold } ] I want to create a function that get object by key such as: myFunc("mode"); returns { mode: "hot" } next call of myFunc("mode") returns { mode: "cold

Chapter 15 Solutions

STARTING OUT WITH C++ MPL

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning