Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
Using C++, design a class named sortedArray. In this class include three data members: capacity, size, and arr (a pointer that points to the first element of the array in the heap). In addition, design a member function named insert that adds elements to the end of the array and a function print that prints the elements of the array, which is equal to size. The elements of the array should be sorted. Create a member function called moveTowardEnd to be able to insert a new element and move the rest towards the end of the array. Likewise, create a member function called moveTowardFront to move the elements of the array towards the front after an element of the array is deleted. Create a member function named remove to delete an element of the array using “pass by value” and consequently moves the left-over elements to the front of the array to take place of the deleted element of the array. Output a message if an element not present in the array is attempted to be removed. Test your…
PLEASE CODE IN PYTHON  PLEASE USE NESTED CLASS FUNCTION   Design a Point Class with attributes X and Y coordinates. The Class should have following functions: a) change the coordinates, b) return a 2 element list [x,y] c) print a Point object. d) return distance from this instance to a given [x,y]   Also design a Line Class which has 2 Point attributes. The Line class should have functions for following behaviours: a) Return the length of the line. b) Print the equation of the line c) Find if this instance is equal in length to another line.
Object Oriented Programing: Create a class template for a class named GeneralStackthat holds  • A single data member as an array named stack of size 50 to store certain elements • Three member functions i.e. push(type) to add elements in the Stack, pop() to remove elements from the stack, and currentStatus() to check whether the array is filled or not. (A filled array is an array that has non-zero value at all of its indexes). In the main() function, create three objects with different data types of class General Stack and test the functionality of member functions for various values of data members for these objects.

Chapter 15 Solutions

Starting Out With C++: Early Objects (10th Edition)

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education