Starting Out with C++: Early Objects
Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 18RQE
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
In-class 5: Making an extensible array Language c Write a function to would allow you to extend the size of an array-based pointer. Feels free to come up with your own function signature, what it should return, and your own test cases.
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
In C programming: Write a main() function using the following requirements:• Define a SIZE constant (the value is irrelevant, but for testing, you may want to keep it small enough – no bigger than 5)• Create an array of course pointers using SIZE• Dynamically allocate each element of the array• Call inputAllCourses()• Call printAllCourses().

Chapter 15 Solutions

Starting Out with C++: Early Objects

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