Complex Vector

Write my research paper
Use a simple vector you created before to create two other more complex vectors with A) Memory allocation that doubles size of memory when end reached, and 1/2’s memory when the size reaches 1/4. B) Implemented with a singularly linked list.Main.cpp#include
#include “SimpleVector.h”
//System Libraries
#include //Input/Output Library
using namespace std;
//User Libraries
//Global Constants, no Global Variables are allowed
//Math/Physics/Conversions/Higher Dimensions – i.e. PI, e, etc…
//Function Prototypes
void fillVec(SimpleVector &);
void addVec(SimpleVector &);
void delVec(SimpleVector &);
void prntVec(SimpleVector &,int);
//Execution Begins Here!
int main(int argc, char** argv) {
//Declare Variables
int size;
//Read in the size
cout<<"What size vector to test?"<>size;
SimpleVector sv(size);
//Initialize or input i.e. set variable values
fillVec(sv);
//Display the outputs
prntVec(sv,10);
//Add and subtract from the vector
addVec(sv);
//Display the outputs
prntVec(sv,10);
//Add and subtract from the vector
delVec(sv);
//Display the outputs
prntVec(sv,10);
//Exit stage right or left!
return 0;
}
void addVec(SimpleVector &sv){
int add=sv.size()*0.1;
for(int i=1;i<=add;i++){ sv.push_front(i+add-1); sv.push_back(i-add); } } void delVec(SimpleVector &sv){ int del=sv.size()*0.2; for(int i=1;i<=del;i++){ sv.pop_front(); sv.pop_back(); } } void fillVec(SimpleVector &sv){ for(int i=0;i 0)
delete [] aptr;
}
// memError function. Displays an error message and
// terminates the program when memory allocation fails.
template
void SimpleVector::memError()
{
cout << "ERROR:Cannot allocate memory.n"; exit(EXIT_FAILURE); } // subError function. Displays an error message and * // terminates the program when a subscript is out of range. * template void SimpleVector::subError() { cout << "ERROR: Subscript out of range.n"; exit(EXIT_FAILURE); } // getElementAt function. The argument is a subscript. * // This function returns the value stored at the sub- * // cript in the array. * template T SimpleVector::getElementAt(int sub) { if (sub = arraySize) subError(); return aptr[sub]; } // Overloaded [] operator. The argument is a subscript. * // This function returns a reference to the element * // in the array indexed by the subscript. * template T &SimpleVector::operator[](const int &sub) { if (sub = arraySize) subError(); return aptr[sub]; } #endif ©Copyright 2000-2018. All Rights Reserved. TermPaperChampions.com: The most reliable provider of custom academic papers. Our writers are here to help you complete papers from all disciplines and academic levels . You can always trust us to deliver.