Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am tasked with making a resizeable array with constructors and using and a template class. I am not familiar with this stuff, hence i
I am tasked with making a resizeable array with constructors and using
Code Below (Need to Fill):
#ifndef DARRAY_H
#define DARRAY_H
#include
template
class DArray
{
public:
/*int length;
int *pa;
int nextIndexl;
*/
DArray:: Darray()
{/*implementation cosntructor*/
};
DArray( size_t count )
{/*implementation
overloaded constructor (dynamically allocate the array with size of count*/
}
DArray( std::initializer_listinitList )
{/*implementation
takes in a list and you want to dynamically allocate the arraty from the list*/};
DArray( const DArray& other)
{/*implementation
getting the reference from another array*/};
DArray& operator=(const DArray &other)
{/*implementation
overloaded operator (allows to use the assignment operator to declare another array)*/
DArray instance1;
return instance1;
};
~DArray();
T& at( size_t pos )
{/*implementation*/};
const T& at( size_t pos ) const
{/*implementation*/};
T& front()
{/*implementation*/};
const T& front() const
{/*implementation*/};
T& back()
{/*implementation*/};
const T& back() const
{/*implementation*/};
void clear()
{/*implementation*/};
void pop_back()
{/*implementation*/};
void push_back( const T& )
{/*implementation*/};
void resize( size_t count )
{/*implementation*/};
bool empty() const
{/*implementation*/};
size_t size() const
{/*implementation*/};
void reserve( size_t new_cap )
{/*implementation*/};
size_t capacity() const
{/*implementation*/};
T& operator[]( size_t pos );
const T& operator[]( size_t pos ) const;
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started