Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 11, Problem 4PP

Enhance the definition of the class StringVar given in Displays 11.11 and 11.12by adding all of the following:

  • Member function copyPiece, which returns a specified substring; member function oneChar, which returns a specified single character; and member function setChar, which changes a specified character
  • An overloaded version of the == operator (note that only the string values have to be equal; the values of maxLength need not be the same)
  • An overloaded version of + that performs concatenation of strings of type StringVar
  • An overloaded version of the extraction operator >> that reads one word (as opposed to inputLine, which reads a whole line)

    If you did the section on overloading the assignment operator, then add it as well. Also write a suitable test program and thoroughly test your class definition.

Blurred answer
Students have asked these similar questions
Poker card in PythonLet the CarteBase class present itself in the context of this exercise. It encapsulates a game card characterized by numerical values for its face and its kind. The possible faces are integers from 1 to 13, with face 1 corresponding to the ace, and faces 11, 12 and 13 corresponding respectively to the jack, the queen and the king. The other faces are simply identified by their number from 2 to 10. The possible grades are integers from 1 to 4 corresponding respectively to the cards of spade, heart, tile and clover. Analyze this class to understand how it works. You are asked to create a class called CarteDePoker that inherits CarteBase and defines or redefines the following methods: force(self) which returns the strength of the card in the poker game. In Poker, cards have the strength of their digital face from 2 to 13, except for the ace which is stronger than the other cards. So we give it a strength of 14.__eq__(self, other) to define operator behavior…
The class definition for an Item is given in the image UML diagram below Note: getInfo() returns a string containing ALL of the state information neatly organized. Part 1:  Create a class based on the specification above. Reminder:  – means private and +  means public. Part 2:  a)Write a function/method called “addItem” that takes: An array of items The number of items in the array An integer representing a barcode A string representing the name of an item A string representing the description of an item A double value representing the price   The function must create and add the item to the array if there is space. The function must return “true” if the addition was successful and “false” otherwise.   b)Write a function/method called “listItems” that takes: An array of items The number of items in the array The function must return a string containing the information on each item in the array.   c)Write a function called “pricelookup” that takes : An array of items The number of…
Implement a class named Animal has two private member variables: name of type string and numLegs of type int, and has the following member functions: • setName—Function to set the name • setNumLegs—Function to set the number of animal legs • getName—Value-returning function to return the name • getNumLegs—Value-returning function to return the number of animal legs • speak()—Value-returning function to return the empty string • move()—Value-returning function to return the empty string • print()—Outputs the data stored in the instance variables with the appropriate titles • Constructor with parameter—Sets the values of the instance variables to the values specified by the user, in default: sets name to the empty string and number of legs to 0 2. Using an Animal class as a base class, implement two derived classes simulating a Cat and Dog, each redefining three functions constructor, speak(), move() to represent each animal the most suitable. 3. Write a function to handle the…

Chapter 11 Solutions

Problem Solving with C++ (10th Edition)

Ch. 11.1 - Given the following definitions: const int x = 17;...Ch. 11.2 - What is the difference between a (binary) operator...Ch. 11.2 - Prob. 13STECh. 11.2 - Suppose you wish to overload the operator = so...Ch. 11.2 - Prob. 15STECh. 11.2 - Give the definition for the constructor discussed...Ch. 11.2 - Here is a definition of a class called Pairs....Ch. 11.2 - Following is the definition for a class called...Ch. 11.3 - Give a type definition for a structure called...Ch. 11.3 - Write a program that reads in five amounts of...Ch. 11.3 - Change the class TemperatureList given in Display...Ch. 11.3 - Prob. 22STECh. 11.3 - If a class is named MyClass and it has a...Ch. 11.4 - Prob. 24STECh. 11.4 - The following is the first line of the copy...Ch. 11.4 - Answer these questions about destructors. a. What...Ch. 11.4 - a. Explain carefully why no overloaded assignment...Ch. 11 - Modify the definition of the class Money shown in...Ch. 11 - Self-Test Exercise 17 asked you to overload the...Ch. 11 - Self-Test Exercise 18 asked you to overload the...Ch. 11 - Prob. 1PPCh. 11 - Define a class for rational numbers. A rational...Ch. 11 - Define a class for complex numbers. A complex...Ch. 11 - Enhance the definition of the class StringVar...Ch. 11 - Define a class called List that can hold a list of...Ch. 11 - Define a class called StringSet that will be used...Ch. 11 - This programming project requires you to complete...Ch. 11 - Redo Programming Project 6 from Chapter 9 (or do...Ch. 11 - Solution to Programming Project 11.12 To combat...Ch. 11 - Repeat Programming Project 11 from Chapter 10 but...Ch. 11 - Do Programming Project 19 from Chapter 8 except...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY