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

  Write a computer program to randomize integers 1 through 999

Write computer programs to sort these numbers in the increasing order using the following algorithms

  Design analgorithm that decides for each node

Design an O(n) algorithm that decides (schedules) for each node at which time slot to start sending data such that the total number of time (slots) is minimized.

  Describe different structures and areas within the brain.

Discuss in detail the thalamus, hypothalamus, endocrine and limbic systems.

  Implementation and application of data structures

Implementation and Application of Data Structures

  Analogue of max flow min cut theorem-capacitated network

Explain how to define the s-t cut on node capacitated network as opposed to edge capacitated network, and how would one illustrate that analogue of the max flow min cut theorem.

  1 introductionyou will create a c program to evaluate

1 introductionyou will create a c program to evaluate expressions combining set union set intersection and parentheses.

  Design a circular double linked list

Design a circular double linked list, for which the following operations should be implemented

  If you can monitor when sql injections are performed on an

if you can monitor when sql injections are performed on an sql database what would you recommend as a security

  You assign each int with a particular id

You assign each int with a particular ID.Array (4, 5, 6, 5, 4, 6) ID (1, 2, 3, 4, 5, 6)

  Questionneural and tree learning on continuous attributesa

questionneural and tree learning on continuous attributesa in general feedforward neural networks multi-layer

  Question about isdn

Today ISDN cost $40 every month for BRI service which includes 1 D Channel and 2 B Channels. Every channel is capable of transmitting 64kbps of voice, data, video or fax for a total of 128 kbps.

  Creating the flowchart for the decision structure

A telephone corporation service plan charges twenty-five cents for each call made. In addition, it charges five cents a minute for all calls made to a phone number that has a service plan with the corporation.

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