Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 15, Problem 20RQE
Program Plan Intro
- 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.
- In private, define the pure virtual function “compare()”.
- 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.
- In private, define the pure virtual function “compare()”.
- 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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 (10th Edition)
Ch. 15.3 - Prob. 15.1CPCh. 15.3 - Prob. 15.2CPCh. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - How can you tell from looking at a class...Ch. 15.3 - What makes an abstract class different from other...Ch. 15.3 - Examine the following classes. The table lists the...Ch. 15 - A class that cannot be instantiated is a(n) _____...
Ch. 15 - A member function of a class that is not...Ch. 15 - A class with at least one pure virtual member...Ch. 15 - In order to use dynamic binding, a member function...Ch. 15 - Static binding takes place at _____ time.Ch. 15 - Prob. 6RQECh. 15 - Prob. 7RQECh. 15 - Prob. 8RQECh. 15 - The is-a relation between classes is best...Ch. 15 - The has-a relation between classes is best...Ch. 15 - If every C1 class object can be used as a C2 class...Ch. 15 - A collection of abstract classes defining an...Ch. 15 - The keyword _____ prevents a virtual member...Ch. 15 - To have the compiler check that a virtual member...Ch. 15 - C++ Language Elements Suppose that the classes Dog...Ch. 15 - Will the statement pAnimal = new Cat; compile?Ch. 15 - Will the statement pCreature = new Dog ; compile?Ch. 15 - Will the statement pCat = new Animal; compile?Ch. 15 - Rewrite the following two statements to get them...Ch. 15 - Prob. 20RQECh. 15 - Find all errors in the following fragment of code,...Ch. 15 - Soft Skills 22. Suppose that you need to have a...Ch. 15 - Prob. 1PCCh. 15 - Prob. 2PCCh. 15 - Sequence Sum A sequence of integers such as 1, 3,...Ch. 15 - Prob. 4PCCh. 15 - File Filter A file filter reads an input file,...Ch. 15 - Prob. 6PCCh. 15 - Bumper Shapes Write a program that creates two...Ch. 15 - Bow Tie In Tying It All Together, we defined a...
Knowledge Booster
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
- 03 Inheritance / Polymorphism Task 1 Currently, you are using composition by creating an instance of a vector / ArrayList inside your AddressBook. This works fine but if we really think about it, and AddressBook is a collection like a stack or a queue or a vector for that matter. Your task is to: C++ derive AddressBook from vector. In other words, use the vector as a base class and derive AddressBook from it. This means that you will need to remove the Vector from the private section of your class. You are going to have to make some fundamental changes to your AddressBook so that you are using the vector / ArrayList functionality to store and retrieve people. In other words, you should be accessing the ArrayList / vector using this. C++ people, don’t forget you are returning pointers in the accessors of the AddressBook class Test your AddressBook the same way you did for assignment 2. If you have coded everything properly it should work the same. Task 2 Create class called Player that…arrow_forwardmember and non-member functions c++arrow_forwardJAVA LANGUAGEarrow_forward
- T or F -Functions are considered to be objects in JavaScript because they contain three critical attributes: data, methods that act on the data, parameters for passing the data also known as awareness. -A recursive function is a function that calls itself and eventually returns default value to break out of the recursion. -A function that is used to create a new object is called an anonymous function. -Attributes define additional characteristics or properties of the element which is the same as for the start tag. -Javascript is similar to the Java programming languagearrow_forwardDon't use vector array .using c++ languagearrow_forwardC++ Programming D.S.Malik12-10: Add the function max as an abstract function to the class arrayListType to return the largest element of the list. Also, write the definition of the function max in the class unorderedArrayListType and write a program to test this function.arrow_forward
- Data Structures and Algorithms in C/C++ In this assignment, you will be using quicksort to sort an array of car objects by various criteria Define a struct Car as follow: #define MAX_STRING_LENGTH typedef struct Car_ { char make[MAX_STRING_LENGTH]; char model[MAX_STRING_LENGTH]; int mpg; /* Miles per gallon */ } Car; Implement a function called compareCarsByMakeThenModel that can be passed as an argument to the compare parameter of the qksort function from the book. compareCarsByMakeThenModel should return a value that will cause qksort to sort an array of cars in ascending order (from smallest to largest) by make and, when two cars have the same make, in ascending order by model. Implement a function called compareCarsByDescendingMPG that can be passed as an argument to the compare parameter of the qksort function from the book. compareCarsByDescendingMPG should return a value that will cause qksort to sort an array of cars in descending order (from largest to smallest)…arrow_forwardOCAML Programming language Sliding tiles The mechanics described in this exercise can be used to implement a game sliding tiles. 1. Create a type slidingTile, consisting of a char matrix and two integers x and y. The integers x and y are the coordinates of an empty tile. 2. Create a function val slide : slidingTile -> int -> int -> slidingTile = <fun> that given a slidingTile and two integers, that represent a location in the matrix, it slides the tile from the specified location to the empty tile, then returns the altered sliding Tile. If provided location is not adjacent to the empty tile, or out of bounds, then return the slidingTile unaltered. 3.Create a function val print_tile : slidingTile -> unit = <fun> that prints a sliding Tile on screen with the corresponding characters from the matrix. However, print an empty space where the empty tile is instead.arrow_forwardUsing c++ Find student with highest GPA Complete the Course class by implementing the FindStudentHighestGpa() member function, which returns the Student object with the highest GPA in the course. Assume that no two students have the same highest GPA. Given classes: Class Course represents a course, which contains a vector of Student objects as a course roster. (Type your code in here.) Class Student represents a classroom student, which has three private data members: first name, last name, and GPA. (Hint: GetGPA() returns a student's GPA.) Note: For testing purposes, different student values will be used. Ex. For the following students: Henry Nguyen 3.5 Brenda Stern 2.0 Lynda Robison 3.2 Sonya King 3.9 the output is: Top student: Sonya King (GPA: 3.9) #include <iostream>#include "Course.h"using namespace std; Student Course::FindStudentHighestGpa() { /* Type your code here */} void Course::AddStudent(Student s) { roster.push_back(s);}arrow_forward
- in c++ language pleasssearrow_forwardC++ Program You may use the vector and iostream libraries. You are allowed to use three built-in vector member functions (and no others) but you may not have to use them all. The member functions you are allowed to use are size(), at(), and push_back() Write a function that outputs a vector of doubles with each number in the vector separated by a space then a newline after the entire vector is output. The whole vector output should be preceded by a single line saying "Current Vector Contents:". Write a function that takes a vector a doubles and reverses the order of all the elements of the vector. Write a function that fills a vector of doubles with positive numbers using the standard input stream cin, terminate the input when the user enters any negative number. A single output prompt should precede the initial input stating directions for user. Write a main function that creates an empty vector, calls functions from 2 & 3 and calls your output function before and after each…arrow_forwardc++ make a simple prrogram that takes random 2d array entered by user and organizes it use pointers for example if the user enter ((8,4),(3,4),(7,2),(8,6),(3,1)) no limit to number of sets use pointers there should be a function called transformer that will transform them into the right order and a funtion called display that will display what was inputed then it would organize it into ((4,8),(3,4),(2,7),(6,8),(1,3)) IT should only modify it and not make a copy of it.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning