Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 8, Problem 4PP

Cumulatively modify the example from Display 8.7 as follows.

  1. In Display 8.7, replace the private char members first and second with an array of char of size 100 and a private data member named size. Provide a default constructor that initializes Size to 10 and sets the first 10 of the char positions to • . (This only uses 10 of the possible 100 slots.) Provide an accessor function that returns the value of the private member size.
  2. Test.

  3. Add an operator member that returns a char& that allows the user to access or to set any member of the private data array using a non-negative index that is less than size.
  4. Test.

  5. Add a constructor that takes an int argument, sz, that sets the first sz members of the char array to ' # '.
  6. Test.

  7. Add a constructor that takes an int argument, sz, and an array of char of size sz. The constructor should set the first sz members of the private data array to the sz members of the argument array of char.
  8. Test.

NOTES: When you test, you should test with known good values, with data on boundaries and with deliberately bad values. You are not required to put checks for index out of bounds errors in your code, but that would be a nice touch. Error handling alternatives: Issue an error message then die (that is, call exit (1)) or give the user another chance to make a correct entry.

Blurred answer
Students have asked these similar questions
displays the entire anagram.cpp application. To indicate the phrase to be anagrammed, use a class. The class's member methods enable the phrase to be displayed, anagrammed, and rotated. The main() procedure receives a word from the user, constructs a word object with this word as an input, and uses the anagram() member function to anagram the word.
With the coding below ,Complete the part labelled ‘//2 a) i’, write the constructor function that outputs “~~Building Created~~” and labelled //2 a) ii’, write the codes to define function findLargest(…). This function will receive an array of 5 Room objects and display the area width x length) of each object. The largest room area will be determined and displayed accordingly. #include <iostream> using namespace std; class Room { int width, length; public: // 2 a)to complete void setData (int L, int T) { width = L; length = T; } friend class Building; } ; class Building { string name; public: Building() { name = "Building"; cout<<"----Buiding name : "<<name<<"-------"<<endl; } // 2 a)to complete }; int main() { Building B1; Room r[5]; int i = 0, x, y; while( i < 5 ) { cout<<"Enter the tables' width and length :\n"; cin>>x>>y; r[i]. setData(x,y); i++; } B1.findLargest(r); return 0; }
Create a class: “Palindrome” with private data members: upper_limit (int), lower_limit (int), and parameterized constructor, which initializes the values of both data members. Apart from initialization, this constructor also displays the count of palindrome numbers from upper_limit to lower_limit. [Example: upper_limit:50, lower_limit:10, count of palindrome numbers is: 4(11, 22, 33 and 44), also make sure the value of upper_limit should be greater than lower_limit].

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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License