Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

template class Array { public: using value_type = T; // Iterators are just pointers to objects of type T using iterator = value_type*; using const_iterator

template

class Array

{

public:

using value_type = T;

// Iterators are just pointers to objects of type T

using iterator = value_type*;

using const_iterator = const value_type*;

using reference = value_type&;

using const_reference = const value_type&;

using size_type = size_t;

using difference_type = ptrdiff_t;

void

push_back (const T& item)

{

insert(end(),item);

}

// TODO!

// Change the size to be "newSize".

// If "newSize" is less than "size",

// erase the last elements.

// If "newSize" is more than "size",

// insert "value"-s at the end.

void

resize (size_t newSize, const T& value = T ())

{

}

// TODO!

// Insert "item" before "pos", and return iterator pointing to "item".

// If the capacity is insufficient, DOUBLE it.

// If the capacity is 0, increase it to 1.

// NOTE: If a reallocation occurs, "pos" will be invalidated!

iterator

insert (iterator pos, const T& item)

{

}

private:

// Stores the number of elements in the Array.

size_t m_size;

// Stores the capacity of the Array, which must be at least "m_size".

size_t m_capacity;

// Stores a pointer to the first element in the Array.

T* m_array;

};

Help with

void

resize (size_t newSize, const T& value = T ())

{

}

and

iterator

insert (iterator pos, const T& item)

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

Students also viewed these Databases questions