Question: Using C++, Modify your own templated vector class and compare it with the std::vector class. Copy this vector.hpp file: #include template class vector { private:

Using C++,

Modify your own templated vector class and compare it with the std::vector class. Copy this vector.hpp file:

#include  template  class vector { private: T *v; int s; public: vector(){ s=0; v=NULL; } ~vector(){ delete [] v; } int size() { return s; } void push_back(T ele) { T *temp; temp = new T[++s]; for(int i=0; i 

and try_vector.cpp file :

#include "./vector.hpp" #include  #include  //We do not want to include either stmt. We wouldn't //be able to compare our vector template to the Standard //using namespace std; //using std::vector; using std::cout; using std::endl; int main (){ vector v; //Our vector class std::vector stdv; //Standard vector //Compare operation of our vector to std v.push_back(23); stdv.push_back(23); return 0; } 

At this time, you do not need to have a capacity member. You need to finish implementing the Big Three(copy constructor, overload operator, and deconstructor), since the vector has dynamic memory. Copy Constructor: vector(vector &other){ } Assignment Operator Overload: void operator=(vector &other){ }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!