Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862218
Author: Walter Savitch
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
a) Implement a class Point with three attributes, x, y, and z.b) Implement an init method with an optional parameter type:       1) Set the default value of x, y, and z to 0.c) Implement a display method to print the values of x, y, and z as the example output below.d) Instantiate two objects of type Point, one with arguments,1, 2, and 3, and the other one without any arguments.e) Call display() to print x, y, and z. Example Output(x, y, z): (1, 2, 3)(x, y, z) : (0, 0, 0)
1) Consider the following class Date, which represents a date using three ints for month, day and year: class Date { private:  int month;  int day; int year; public:  Date() { month = day = year = 0; }  Date(int m, int d, int y) { month = m; day = d; year = y; }  bool operator==(Date);  bool operator<(Date); }; It asks to create an implementation for both overloaded operators. == should return true if the Date objects are equivalent and false if not.  < should return true if the Date of the calling object (left object) comes before the parameter Date object (right object) and false if not. Assume that all objects of class Date are valid, i.e. month is between 1 and 12, inclusive; day contains an appropriate day for the given month, and year can be anything. You don't need to demonstrate calling these operators.
2)   Consider the following class   class Department { private: string name; const long locationNo; const longdeptId; intNumOfEmployees; static intnextDeptNo; static intnextLocationNo;   public: Department( ); Department(string theName, totalEmps) void Print ( ) const; }   Initialize both the values of nextDeptNo and nextLocationNo to 10000 Implement the default constructor to set the name to “Unknown”, locationNo to the current value of nextLocationNo, deptId to the current value of nextDeptNo and NumOfEmployees to zero. It should also increment the value of all static attributes by 1. Implement the other constructor to set the name and NumOfEmployees to the values that are passed to the contractor. The values of the locationNo and deptId should be assigned to the current values of nextLocationNo and nextDeptNo, respectively. This constructor should also increment the values of all static attributes by 1. The print function should print all values of all attributes (regular,…

Chapter 11 Solutions

Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th 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...

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