Question: hello, my code is attatched and i need help filling in the functions that i have commented out in the program, please write comments explaining

hello, my code is attatched and i need help filling in the functions that i have commented out in the program,

please write comments explaining what, why so i can use this as a learning experience and learn from it. thank you

i need help filling in the

void pushback, void popback, int front(), it back(), size_t size(), bool empty, void check overflow.

instructions and code attahced below

#include

#include

#include

class int_vector {

public :

int_vector() : capacity_(minCapacity_), size_(0), data_(new int[size_]) {

std:: cout

}

int_vector(const std::initializer_list& li): int_vector(){

for(int i : li){

*(data_ + size_) = i;

++size_;

}

}

int_vector(const int_vector& other) : data_(nullptr){

std::cout

copy(other);

} //copy c'tor

int_vector& operator = (const int_vector& other){

if(this == &other) {copy(other);}

copy(other);

return *this;

}

void copy(const int_vector& other){

if(data_ != nullptr) {delete[] data_;}

capacity_ = other.capacity_;

size_ = other.size_;

data_ = new int[size_];

memcpy(data_, other.data_, size_* sizeof(int));

}

~int_vector(){

std::cout

delete[] data_;

}

int operator[](size_t idx) const{ return *(data_ + idx);} //read-only

int& operator[](size_t idx) { return *(data_ + idx);} //rewrite

//size_t count() const;

//bool empty() const;

//int front() const;

//int back() const;

//void push_back(int value){

//check_overflow();

// data_[size_++] = value;

// }

// void pop_back();

//void check_overflow() const{

// if(size_ == capacity_){

// throw new std::invalid_argument("overflow");

// }

// }

//void check_empty() const;

friend std::ostream& operator

if (iv.size_ == 0) {

return os

}

os

for (size_t i = 0; i

os

}

return os

}

private :

const size_t minCapacity_ = 10;

size_t capacity_;

size_t size_;

int* data_;

};

int main() {

int_vector ivdefault;

int_vector iv2({3,1,4,1,5,9,2,6,5});

int_vector ivcopycted= iv2;

ivdefault= iv2;

iv2[0]=2;

iv2[1]=7;

iv2[2]=1;

//int_vector iv2 = iv;

// int_vector iv3;

// iv3 = iv;

// std::cout

//std::cout

// std::cout

//iv[0] = 999;

// std::cout

std::cout

return 0;

}

hello, my code is attatched and i need help filling in thefunctions that i have commented out in the program, please write comments

LAB: int_vector class (prelude to vector class - templated class) O0 class design is This lab, based on Effective C++ by Scott manages dynamic releasing (array delete tt Meyers, is designed to give practice in creating a class memory. This type of class requires special care in allocating (array new), and )memory. In particular, the following must now be written by the class copy constructor (int_vector(const int vector copy assignment operator (int-vector& operator=(const int-vector&), destructor (C-int vectorO) The following book may prove useful when doing this lab: https://doc.lagout.org/programmation/C/Addison. Wesley.Effective.CPP.3rd.Edition.May.2005,pdf Also, the documentation on std:vector has a more extensive form of the interface that we are implementing here. You can see this documentation at: http://www.cplusplus.com and http://en.cppreference.com #inc lude #include #include class int vector public: int vector) int_ vector (const std: initializer 1ist more work for us II dyna page 1 of 2 LAB: int vector class McCar

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!