Answered step by step
Verified Expert Solution
Link Copied!

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 and a template class. I am not familiar with this stuff, hence i turn to here for help. Below is what I am tasked with. Some guidance on this subject would be much appreciated. Program is in C++:

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_list initList ) 
 {/*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

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

=+1. If you were a judge hearing this case, how would you rule?

Answered: 1 week ago