QuestionQuestion

For this project you will create a template class BigArray. It will be a fully functional type. It will contain the following:
// Vindex is the virtual index of the first element in your BigArray
BigArray ( int Vindex = 0 );
//****************************************************************/
// s is the number of items pointed to by T*
// Vindex is the virtual index of the first element in your BigArray
BigArray ( const T*, unsigned s, int Vindex = 0 );
//****************************************************************/
//Copy constructor
BigArray ( const BigArray& );
//****************************************************************/
//Destructor
~BigArray ( ); //1
//****************************************************************/
//Assignment
BigArray<T>& operator= ( const BigArray<T>& ); //1
//****************************************************************/
// Insert the array or a pointer to an array into an ostream
template <typename OS>
friend ostream& operator<< ( ostream&, const BigArray<OS>& );
template <typename OS>
friend ostream& operator<< ( ostream&, const BigArray<OS>* );
//****************************************************************/
// access the item at index 0<= Vindex <Size (assuming standard indexing)i
T& operator[] ( int Vindex );
const T& operator[] ( int Vindex ) const;
//****************************************************************/
// Returns a sub array from virtual index Vfirst to index Vlast-1
BigArray operator( ) ( int Vfirst, int Vlast )const;
//****************************************************************/
// Append either a new item or another BigArray beginning at index Size
void append ( const T& ); //2
void append ( const BigArray& );

1. There MUST NOT be any call to operator delete except in ~RubberArray, append, and operator=
2 .There MUST NOT be any call to operator new except in void append ( const T& );

// return the number of items in the array
unsigned length ( ) const;
//****************************************************************/
// Add a new item at index 0 <= Vindex < Size (assuming standard indexing)i
void add ( int Vindex, const T& );
// Add a new item at index 0 (assuming standard indexing)i
void add ( const T& );
//****************************************************************/
// Remove the item at index Size-1 (assuming standard indexing)i
void remove ( );
// Remove the item at index 0 <= Vindex <Size (assuming standard indexing)i
void remove ( int Vindex );
// Remove the items from index Vfirst through index Vlast-1
void remove ( int Vfirst, int Vlast );

Templates work a little differently than regular classes. You will turn in one file named: BigArray.h //Do not implement functions within the class
We will not be using the Power server for this assignment. You must us the CodeBlocks compiler.
You must check the “Global Compiler Settings” boxes that set –Wall & –pedantic–errors.
This array must grow and shrink as items are added and deleted from it. You will begin with zero allocated space. The first time an item is added you will allocate space for that one item. The next time an item is added, you will add space for two items. The amount of space added will double every time you need more space in your BigArray. The BigArray must shrink the same way.

Items in the BigArray Allocated space
0 0
1 1 (added 1)
2 3 (added 2)
3 3
4 7 (added 4)
5 7
6 7
7 7
8 15 (added 8)

15 15
16 31 (added 16)

The standard indexing for your array will be zero but this can be set in the constructor. This means that there is a virtual index that the user sees as the index of the first item in the BigArray. It might be zero or 15, or -50. Of course, internally, your BigArray will use an actual index which always starts at zero. One of the challenges of this assignment is keeping these two things straight. You must check every index parameter to see if it is in range. If an index is out-of-range, display an error message and call exit(1).

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>
#include "BigArray.h"
using namespace std;

int main()
{
    BigArray<int> big ;
    big.add(7);
    big.add(10);
    big.append(15);
   
    for (unsigned int i = 0; i < big.length(); i++) {
    //   cout<<big[i]<<" ";   

    }
    big.append(big);
   
    for (unsigned int i = 0; i < big.length(); i++) {
       cout<<big[i]<<" ";   
    }   
}...
$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats