Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10, Problem 28RQE
What does the get ( ) method of the unique_ptr classs do?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What are the benefits of having a destructor for a class?
C++ assigment:
It's a Number Guesser assignment. It asks to write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class should override the behavior of the getCurrentGuess method. It may also add member data and its own constructor. It may also override the higher(), lower() and reset() methods as you see fit.
This is the code for NumberGuesser class. It is defined entirely in-line in the following file: NumberGuesser.h
// NumberGuesser.h
// #ifndef NUMBERGUESSER_H
#define NUMBERGUESSER_H
#include <iostream>
class NumberGuesser
{
protected:
int low;
int originalLow;
int high;
int originalHigh;
public:
NumberGuesser(int l, int h) {
low = originalLow = l; high = originalHigh = h;
}
virtual int getCurrentGuess() {
return (high + low) / 2;
}
virtual void higher() {
low = getCurrentGuess() + 1;
}
virtual void lower() {
high = getCurrentGuess() - 1;
}
virtual…
C++ assigment:
It's a Number Guesser assignment. It asks to write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class should override the behavior of the getCurrentGuess method. It may also add member data and its own constructor. It may also override the higher(), lower() and reset() methods as you see fit.
This is the code for NumberGuesser class. It is defined entirely in-line in the following file: NumberGuesser.h
// NumberGuesser.h
// #ifndef NUMBERGUESSER_H
#define NUMBERGUESSER_H
#include <iostream>
class NumberGuesser
{
protected:
int low;
int originalLow;
int high;
int originalHigh;
public:
NumberGuesser(int l, int h) {
low = originalLow = l; high = originalHigh = h;
}
virtual int getCurrentGuess() {
return (high + low) / 2;
}
virtual void higher() {
low = getCurrentGuess() + 1;
}
virtual void lower() {
high = getCurrentGuess() - 1;
}
virtual…
Chapter 10 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 10.5 - Prob. 10.1CPCh. 10.5 - Write a statement defining a variable dPtr. The...Ch. 10.5 - List three uses of the symbol in C++.Ch. 10.5 - What is the output of the following program?...Ch. 10.5 - Rewrite the following loop so it uses pointer...Ch. 10.5 - Prob. 10.6CPCh. 10.5 - Assume pint is a pointer variable. For each of the...Ch. 10.5 - For each of the following variable definitions,...Ch. 10.10 - Assuming array is an array of ints, which of the...Ch. 10.10 - Give an example of the proper way to call the...
Ch. 10.10 - Complete the following program skeleton. When...Ch. 10.10 - Look at the following array definition: const int...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Prob. 10.15CPCh. 10.10 - Prob. 10.16CPCh. 10.10 - Prob. 10.17CPCh. 10.12 - Prob. 10.18CPCh. 10.12 - Assume the following structure declaration exists...Ch. 10.12 - Prob. 10.20CPCh. 10 - Each byte in memory is assigned a unique _____Ch. 10 - The _____ operator can be used to determine a...Ch. 10 - Prob. 3RQECh. 10 - The _____ operator can be used to work with the...Ch. 10 - Prob. 5RQECh. 10 - Creating variables while a program is running is...Ch. 10 - Prob. 7RQECh. 10 - If the new operator cannot allocate the amount of...Ch. 10 - Prob. 9RQECh. 10 - When a program is finished with a chunk of...Ch. 10 - You should only use the delete operator to...Ch. 10 - What does the indirection operator do?Ch. 10 - Look at the following code. int X = 7; int ptr =...Ch. 10 - Name two different uses for the C++ operator.Ch. 10 - Prob. 15RQECh. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - What is the purpose of the new operator?Ch. 10 - What happens when a program uses the new operator...Ch. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - Prob. 25RQECh. 10 - Prob. 26RQECh. 10 - What happens when a unique_ptr that is managing an...Ch. 10 - What does the get ( ) method of the unique_ptr...Ch. 10 - Prob. 29RQECh. 10 - Prob. 30RQECh. 10 - Prob. 31RQECh. 10 - Prob. 32RQECh. 10 - Consider the function void change(int p) { P = 20;...Ch. 10 - Prob. 34RQECh. 10 - Write a function whose prototype is void...Ch. 10 - Write a function void switchEnds(int array, int...Ch. 10 - Given the variable initializations int a[5] = {0,...Ch. 10 - Each of the following declarations and program...Ch. 10 - Prob. 39RQECh. 10 - Test Scores #1 Write a program that dynamically...Ch. 10 - Test Scores #2 Modify the program of Programming...Ch. 10 - Indirect Sorting Through Pointers #1 Consider a...Ch. 10 - Indirect Sorting Through Pointers #2 Write a...Ch. 10 - Pie a la Mode In statistics the mode of a set of...Ch. 10 - Median Function In statistics the median of a set...Ch. 10 - Movie Statistics Write a program that can be used...Ch. 10 - Days in Current Month Write a program that can...Ch. 10 - Age Write a program that asks for the users name...Ch. 10 - Prob. 10PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
This statement can cause other program statements to execute only under certain conditions. 1. Conditional 2. D...
Starting Out With Visual Basic (8th Edition)
The strength of a pull broach is determined by its minimum cross section, which usually occurs either at the ro...
Degarmo's Materials And Processes In Manufacturing
What is software?
Java: An Introduction to Problem Solving and Programming (8th Edition)
Describe the primary differences between the conceptual and logical data models.
Modern Database Management
Determine the moment reactions at the supports A and B. Use the method of integration. El is constant.
Mechanics of Materials (10th Edition)
The current source in the circuit shown generates the current pulse
Find (a) v (0); (b) the instant of time gr...
Electric Circuits. (11th Edition)
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
- class GradedActivity { private: double score; public: GradedActivity() { score = 0.0; } GradedActivity(double s) { score = s; } void setScore(double s) { score = s; } double getScore() { return score; } char getLetterGrade() const; }; Implement the GradedActivity class above. In this C++ assignment, create a new class Assignment which is derived from GradedActivity. It should have three private member ints for 3 different parts of an assignment score: functionality (max 50 points), efficiency (max 25 points), and style (max 25 points). Create member function set() in Assignment which takes three parameter ints and sets the member variables. It should also set its score member, which is inherited from GradedActivity, using the setScore() function, to functionality + efficiency + style. Signature: void Assignment::set(int, int, int) Create a main program which instantiates an Assignment, asks the user…arrow_forwardSoftware Requirements: • Latest version of NetBeans IDE • Java Development Kit (JDK) 8 Procedure: 1. our progras from rhFactor non-static and private. Remove the constructor with two (2) parameters. 2o upply uncapsutation Make bloodType and 2. The names of the public setter and getter methods should be: • setBloodType() • setRhFactor() getBlood Type() getRhFactor() 3. Use the setter methods to accept user input. 4. Display the values by calling the getter methods. Sample Output: Enter blood type of patient: Enter the Rhesus factor (+ or -): O+ is added to the blood bank. Enter blood type of patient: B Enter the Rhesus factor (+ or -): B- is added to the blood bank.arrow_forwardWhy does a destructor in base class need to be declared virtual?arrow_forward
- Lab Goal : This lab was designed to teach you more object oriented programming and start you down the path of creating larger programs and games like BlackJack and Elevens [ one of the new AP CS A Labs ]. You will create a Deck class that contains a List < Card >Lab Description : You need to design a class that contains an instance variables which is a List < Card > and an int that keeps track of the top card position . You then need to make a constructor and related methods. You will need a dealCard method and a shuffle method. Use the template shown below. /make a Deck classpublic static final int NUMCARDS = 52;public static String[] SUITS = "CLUBS HEARTS DIAMONDS SPADES".split(" ");private List<Card> cards;private int top;//make a Deck constructor//refer cards to new ArrayList//set top to the top of the deck 51//loop through all suits//loop through all faces 1 to 13//add a new BlackJackCard to the deck//make a dealCard() method that returns the top card//write…arrow_forwardTRUE OR FALSE A method that uses a generic class parameter can be static or dynamic.arrow_forwardpython question Design BDTeam class and AusTeam class which inherit from CricketTeam class so that the following code provides the expected output.You can not change any of the given code. Do not modify the given parent class.Note:add_player() method in both child classes should work for any number of parameters and assume parameters will be even numbers.class CricketTeam: def __init__(self, name, ranking, continent): self.name = name self.ranking = ranking self.continent = continent def add_player(self, *info): pass def __str__(self): s = f"Name: {self.name}\nRanking: {self.ranking}\nContinent: {self.continent}" return s# Write your codes here.# Do not change the following lines of code.bangladesh = BDTeam("Bangladesh", 7, "South Asia", 1)bangladesh.add_player("Mustafiz", "Bowler", "Mashrafee", "Bowler", "Shakib", "All Rounder", "Tamim", "Batter", "Mahmudullah",…arrow_forward
- class RandomClass {public: RandomCalss operator/(RandomClass); private: int x,y; }; int main() { RandomClass x,y; cout << x / y; <------------------------------------ } What is x / y equivalent to as a function call? topic is operator overloading c++arrow_forwardGiven below is a UML diagram for address class. Address -Street: String -City: String -State: String -Postal code: String -country: String +methods a) Write the code for default constructor and set the values of the data fields to null? b) Write the code for overloaded constructor with formal parameters and set the values of the data fields to the parameter listing. c) Write the code for mutator and accessor methods.arrow_forward18. If a class is declared as final, the incorrect statement is (). A. Indicates that this class is final B. Indicates that this class is a root class C. Methods in this class cannot be overridden D. Variables in this class cannot be hidden 19. In the following description of polymorphism, the incorrect one is (). A. Polymorphism refers to "one definition, multiple implementations" B. There are three types of polymorphism: dynamic polymorphism, static polymorphism, and default polymorphism C. Polymorphism is not used to speed up code D. Polymorphism is one of the core characteristics of OOP 20. In Java, two interfaces B and C have been defined. To define a class that implements these two interfaces, the correct statement is ( ). A. interface A extends B,C B. interface A implements B,C C. class A implements B,C D. class A extends B,C 21. Given the following java code, the correct description of the usage of "super" is (). class Student extends Person{ public Student() { super(); } 3 D…arrow_forward
- Given below is a UML diagram for address class. Address -Street: String -City: String -State: String -Postal code: String -country: String +methods a) Write the code for default constructor and set the values of the data fields to null? b) Write the code for overloaded constructor with formal parameters and set the values of the data fields to the parameter listing. c) Write the code for mutator and accessor methods. d) Write the code for printAddress() method that returns the full address.arrow_forwardwhat is the difference between overriding a super class method and overloading a super class method?arrow_forwardVending Machinearrow_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 LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY