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

Question
Book Icon
Chapter 11, Problem 1PP
Program Plan Intro

Creation of program to construct class for a vector

Program Plan:

  • Define a file “vectorDouble.h” to define properties of vector.
    • Define a function prototype for constructor “VectorDouble()”.
    • Define a function prototype for destructor “~VectorDouble()”.
    • Define a function prototype for method “push_back()”.
    • Define a function prototype for method “value_at()”.
    • Define a function prototype for method “change_value_at()”.
    • Define a function prototype for method “size()”.
    • Define a function prototype for method “capacity()”.
    • Define a function prototype for method “reserve()”.
    • Define a function prototype for method “resize()”.
    • Define a function prototype for method “operator<<()”.
    • Define a function prototype for method “operator==()”.
    • Define a function prototype for method “operator=()”.
    • Define a function prototype for method “expandCapacity()”.
  • Define a file “vectorDouble.cpp” to define properties of vector.
    • Define a method for constructor “VectorDouble()” to create instance of vector.
    • Define a method for destructor “~VectorDouble()” to destroy existing vector instances.
    • Define a method “push_back()” to push value into array.
    • Define a method “value_at()” to return value of element.
    • Define a method “change_value_at()” to change value of element.
    • Define a method “size()” to compute size of array.
    • Define a method “capacity()” to return maximum count possible.
    • Define a method “reserve()” to create new array and reserve space.
    • Define a method “resize()” to resize the existing array.
    • Define a method “operator<<()” to create an overloaded operator.
    • Define a method “operator==()” to create an overloaded operator.
    • Define a method “operator=()” to create an overloaded operator.
    • Define a method “expandCapacity()” to expand capacity of array.
  • Define a file “Source.cpp” to call member functions and methods.
    • Create instance for vector class.
    • Insert values into array.
    • Call method “push_back()” to push value into array.
    • Call method “value_at()” to return value of element.
    • Call method “change_value_at()” to change value of element.
    • Call method “size()” to compute size of array.
    • Call method “capacity()” to return maximum count possible.
    • Call method “reserve()” to create new array and reserve space.
    • Call method “resize()” to resize the existing array.
    • Call method “operator<<()” to create an overloaded operator.
    • Call method “operator==()” to create an overloaded operator.
    • Call method “operator=()” to create an overloaded operator.
    • Call method “expandCapacity()” to expand capacity of array.
    • Display resultant values.

Blurred answer
Students have asked these similar questions
Write in C++ a class Restaurants to manage a vector of Restaurant objects. The class Restaurants should have: • A private vector to store Restaurant objects • A public add method to add a Restaurant to the Restaurants • A public average_max_rating method that returns the average of max ratings of the restaurants. • A public get_max method that returns the Restaurant that has highest max rating.
One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector . This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have the following A private member variable called dynamicArray that references a dynamic array of type string. A private member variable called size that holds the number of entries in the array. A default constructor that sets the dynamic array to NULL and sets size to 0. A function that returns size . A function named addEntry that takes a string as input. The function should create a new dynamic array one element larger than dynamicArray , copy all elements from dynamicArray into the new array, add the new string onto the end of the new array, increment size, delete the old dynamicArray ,…
Design a struct personalinfo with components id, and name of type string. Design a class student with private data member's person (struct variable of type personalInfo), number Of Courses (of type integer), average (of type float), and marks[] an array of student's marks of type integer. The class also has the member functions ser( ), getPerson(), print(), findAverage(), getAverage(), and a parameterized constructor with default value 1 for the number of courses. Implement the member functions of the class student. The member function findAverage() is used to calculate the average mark for each student. I Write a driver that does the following: Declares the array section[ ] of objects of student type. Reads the number of students. Reads information for each student from the file student.txt. Calls the user-defined function int maxAverageIndex(int, student []) Prints the id and name of the student with the maximum average. Student.txt: 4 1463491 Ali 72 65 81 85 1370005 Yousef 5 91 82…

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...
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