Question: C++ Dynamic Array Function Below I have the functions from the .h file and I need help with the constructor! template class dynarr { private:

C++ Dynamic Array Function

Below I have the functions from the .h file and I need help with the constructor!

template

class dynarr {

private:

int capacity;

dynElem *A;

public:

dynarr() : capacity(0), A(NULL);

dynarr(int N): capacity(N), A(new dynElem[N]){}

dynarr(const dynarr &other);

~dynarr();

dynarr & operator=( const dynarr &other);

dynElem & operator[](int ndx) throw(InvalidIndex);

int getCapacity();

void reserve(int newcap);

// if newcap <= capacity, does nothing;

// if capacity is 0, allocates a dynamic array of

// capacity newcap and makes A point to that array;

// otherwise allocates a new dynamic array newA of capacity

// newcap, copies values in A to newA, deletes A and sets

// A equal to newA

};

Constructor function

template

dynarr::dynarr(const dynarr &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!