Create a vector class called vectordouble

Assignment Help C/C++ Programming
Reference no: EM13937726

Your class VectorDouble will have a private member variable for a dynamic array of doubles. It will also have two member variables of type int; one called maxCount for the size of the dynamic array of doubles, and one called count for the number of array positions currently holding values. (maxCount is the same as the capacity of a vector; count is the same as the size of a vector.)

If you attempt to add an element (a value of type double) to the vector object of the class VectorDouble and there is no more room, then a new dynamic array with twice the capacity of the old dynamic array is created and the values of the old dynamic array are copied to the new dynamic array.

Your class should have all of the following:

- Two constructors: a default constructor that creates a dynamic array for 50 elements and a constructor with one int argument for the number of elements in the initial dynamic array.

- A destructor.

- Member functions push_back, capacity, size, reserve, and resize that behave the same as the member functions of the same names for vectors.

- Two member functions to give your class the same utility as the square brackets: value_at(i), which returns the value of the ith element in the dynamic array; and change_value_at(d,i), which changes the double value at the ith element of the dynamic array to d. Enforce suitable restrictions on the arguments to value_at and change_value_at.

Reference no: EM13937726

Questions Cloud

What do the words mean in the context of dismissing a class : What do the words mean in the context of dismissing a class? Look at the words in their biblical context (Genesis 31:49 --- include the context of the chapter and broader context of the Jacob and Laban story).
Major side effect of stimulant medication treatment : A major side effect of stimulant medication (e.g., Ritalin) treatment for ADHD is _______
Explain why the ending inventory balance : Explain why the ending inventory balance (assuming it is not zero) computed under full costing will always be greater than the ending inventory balance computed under variable costing.
Describe how the project aligns with the organization : Goal of Case Study One is to apply project management skills acquired in the first three modules to a real-world project or situation - Dallion was not given a project charter so he begins the project by creating a charter for approval by management..
Create a vector class called vectordouble : Two constructors: a default constructor that creates a dynamic array for 50 elements and a constructor with one int argument for the number of elements in the initial dynamic array.
Attractiveness of the dairy processing industry : Evaluate the attractiveness of the dairy processing industry in both Hong Kong and mainland China by conducting a systematic analysis of the competitive forces. Specify the key changes that have occurred in this industry since the 2008 melamine-in..
What does the analysis tell you about overall profitabity : What does this analysis tell you about the overall profitability of Accent Company over the 5-year period? What does this analysis tell you about what has happened to Accent's amount of debt over the past 5 years?
Counting and boolean algebra : Counting and Boolean Algebra 1. Given that there are 100 elements in A1, 1000 in A2, and 10, 000 in A3, find the number of elements in A1 ∪ A2 ∪ A3 in each of the cases below.
Which method of computing net income will result : Which method of computing net income will result in the higher net income? Why?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a function that finds area and volume of a cube

write a function that finds area and volume of a cube when length is input and then write a program to test it. here is what i have so far.

  Create a serial object s

The function call operator is overloaded and will generate a sequential integer each time the operator is used and the object can be created with the sequence start value specified.

  Evaluate the mathematical constant of p

Write a C++ program to evaluate the mathematical constant of PI - Guess a random number between 0.00 and 1.00 and assign this to x.

  Approached to create a computer program

Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant.  That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer ..

  To arrange the elements of an integer array

Write a ‘C’ functions to arrange the elements of an integer array in such a way that all the negative elements are before the positive elements. The array is passed to it as an argument.

  Write c++ statements that remove all the items

write C++ statements that remove all the items from storeBag and place them into one of two new bags, as follows: Place all occurrences of bread and eggs into fragileBag, and all other items into groceryBag.

  Program that allows the user to enter two numeric values

Prepare a program that allows the user to enter two numeric values. Then let the user enter a single character as the desired operation, for example 'A', 'a', or '+' for add.

  Calculation the distance and time printed on the screen

After each calculation the distance and time printed on the screen and accumulated to the sum of the total distance and sum of the total time. The current destination should be saved as the old postion for the next calculation

  Give a complete pseudo-code description of the recursive

Give a complete pseudo-code description of the recursive merge-sort algorithm that takes an array as its input and output.

  Implement a time class that represent a specific time of day

Implement a Time class. Each object of this class will represent a specific time of day, storing the hours, minutes, and seconds as integers.

  Programs written with inheritance

Many programs written with inheritance could be written with composition instead, and vice versa. Rewrite the classes Point3D, Sphere and Cylinder using composition rather than inheritance

  Calculates the exact integral over the interval

Write your program so that it outputs the interval entered, the exact solution, the approximation, the number of trapezoids and the difference between the exact and approximate solutions - trapezoids increases the approximate result converges to th..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd