Question: C++ I am making a vector and I can't seem to figure out the last two steps. I need to ... a. A function pop_back

C++

I am making a vector and I can't seem to figure out the last two steps. I need to ...

a. A function pop_back( ) that removes the last used element in the vector.

b. A function at(int n) that returns the value of the element at position n in the vector. If the index n is greater than the size( ) of the vector, this function should throw an exception.

below is in my DynArray.cpp file

void DynArray::pop_back(int)

{

delete data[arraySize + 1]; //doesn't work.. //needs to delete the last thing pushed back. }

int DynArray::at(int) const { . return 0; }

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!