Write a class to represent a dynamically sized array

Assignment Help Data Structure & Algorithms
Reference no: EM131320343

CPSC Program

This is the program

Write a class to represent a dynamically sized array of integers. Name it DynArray.

submit: a file named dynarray.h that contains all of your class code

Class specifications:

Private data members:

data arraysize datasize

- a pointer to integer array data

- an integer representing the array size (allocated space) - an integer representing the amount of data stored in the array Public member functions:

default constructor: Sets the array size to be 10 elements, the data size to be 0, and dynamically allocates the 10 element array space.

constructor receiving size: Checks the size parameter value to make sure that it is a positive (>0) value. If the value is positive, it
becomes the array size.

If the value is not legal, the array size should be set to 10. After setting the array size, the data size is set to 0, and the dynamic allocation is performed.

copy constructor: Receive one DynArray object as a parameter and make the new object a copy of that object with its own separately allocated memory space, but with the same sizes and same data.

destructor: Dynamically de-allocate the array space and set the pointer value to NULL.

setArraySize: This function receives a size value. If the parameter value is

greater than the existing array size, change the array size, allocate a new array space, copy all of the data values to the new space, and deallocate the old array space.

If the size value is invalid (smaller than current size), do nothing.

getArraySize: Return a copy of the array size field.

getDataSize: Return a copy of the data size field.

addValue: Receives an integer value. If there is currently room in the

allocated array space, then store the value into the array. If there is not space, then relocate the array to another location with twice as much space as before, and then store the parameter value into the array.

= operator: Receives one DynArray object as a parameter and makes the current object a copy of that parameter object with its own separately allocated array space. Make sure to de-allocate the current array space before dynamically allocating a new one.

Reference no: EM131320343

Questions Cloud

Discuss the difference in social structure and social class : There are many theories regarding the social construction of serial killers. Discuss the difference in social structure, social class, social process, neutralization, social control, and labeling theories as they relate to serial killers
Implement a 3-to-8 decoder using two 2-to-4 decoders : Implement a 3-to-8 decoder using NOT and AND gates in Logisim. Show that it is correct by showing it generates the same output as a 3-to-8 Decoder found in the Plexors menu of Logisim.
Discuss the beginnings of the cold war : Discuss the beginnings of the Cold War. From the position of a Soviet ruler, how might you have viewed the situation following WWII? How did the Truman administration attempt to handle it? (Include as many of the following as you can: containm..
Defining the problem and analysis of the situation : US photovoltaic company panel installation in Asia.US clothing retailer into Central America. Coffee shop entry into western Africa.Your analysis should be of adequate length to address all areas.
Write a class to represent a dynamically sized array : Write a class to represent a dynamically sized array of integers. Name it DynArray. An integer representing the array size (allocated space) - an integer representing the amount of data stored in the array Public member functions:
What is the new equity value of tyler : What is the new equity value of Tyler on its balance sheet - How much goodwill will Talmadge enter on its balance sheet as a result of this merger?
How use of digital media was used to communicate information : In this assignment, you will locate examples of how the use of digital media was used to communicate information to achieve a specific goal of an organization or individual.
Explain the contributions of three abolitionists : Name and explain the contributions of three Abolitionists that supported and helped African Americans before the Civil War fight slavery?
Toward american independence : What were the key events that marked the move toward American Independence?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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