Question: DONT EDIT HEADER #ifndef MYVECTOR _ H #define MYVECTOR _ H #include #include #include using std::cerr; using std::cin; using std::cout; using std::endl; using std::string; class
DONT EDIT HEADER
#ifndef MYVECTORH
#define MYVECTORH
#include
#include
#include
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::string;
class ArrayListIterator
int index;
public:
ArrayListIteratorint i : indexi
operator int
return index;
allows Iterator to be used like an intindex
ArrayListIterator operatorint increment
index increment;
return this;
allows
bool operatorint comp return index comp;
bool operatorint comp return index comp;
;
template class MyVector
private:
T data nullptr;
int maxelements;
int numelements;
public:
Just a simple default constructor.
MyVector : maxelements numelements data new T;
~MyVector;
const MyVector &operatorconst MyVector &source;
MyVectorconst MyVector &source;
T &operatorint index;
T &atint index;
T &front;
T &back;
unsigned int capacity;
void reserveint newmaxelements;
void shrinktofit;
void clear;
void pushbackconst T &value;
void popback;
void insertArrayListIterator position, const T &value;
void eraseArrayListIterator position;
unsigned int size;
int findconst T &value;
void swapMyVector &other;
ArrayListIterator begin return ArrayListIterator;
ArrayListIterator end return ArrayListIteratornumelements;
;
template
std::ostream &operatorstd::ostream &out, MyVector &mylist
out ;
for int i ; i mylist.size; i
out mylist.ati;
out ;
return out;
#include "MyVector.hpp
#endif
In one of the attached photo, theres the MyVector.hpp but my insert, copy, operator and erase functions dont work. I included the MyVector.h file to refer toCan someone fix these functions for me And also show me how to implement all of this in the main function, I will like if it works!
Following nonfunctional functions from picture below:
template
const MyVector &MyVector::operatorconst MyVector &rhs
if this &rhs
clear;
reserverhscapacity;
for int j ; j rhssize; j
pushbackrhsj;
Finish me
return this;
template MyVector::MyVectorconst MyVector &rhs
reserverhscapacity;
for int j ; j rhssize; j
pushbackrhsj;
template
void MyVector::insertArrayListIterator index, const T &value
int position index;
if position numelements
for int j numelements; j position; j
dataj dataj ;
dataposition value;
numelements numelements ;
if numelements maxelements
reservemaxelements ;
return;
template void MyVector::eraseArrayListIterator index
int position index;
if position numelements
for int j position; j numelements ; j
dataj dataj ;
numelements numelements ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
