Question: C++. A constructor that has two parameters. I'm having difficulty creating a constructor that has two parameters. The parameters are an array of ItemType elements,

C++. A constructor that has two parameters.

I'm having difficulty creating a constructor that has two parameters. The parameters are an array of ItemType elements, and a count of the number of elements in the array. Use the array elements to initialize the set.

This is what I have so far:

//ArraySet.h

#ifndef ARRAY_SET_

#define ARRAY_SET_

#include "SetInterface.hpp"

template

class ArraySet : public SetInterface

{

private:

static const int DEFAULT_CAPACITY = 6; // Small size to test for a full bag

ItemType items[DEFAULT_CAPACITY]; // Array of bag items

int itemCount; // Current count of bag items

int maxItems; // Max capacity of the bag

// Returns either the index of the element in the array items that

// contains the given target or -1, if the array does not contain

// the target.

int getIndexOf(const ItemType& target) const;

public:

//Default constructor

ArraySet();

//Constuctor with parameters

ArraySet();

int getCurrentSize() const;

bool isEmpty() const;

bool add(const ItemType& newEntry, const ItemType& target, int searchIndex);

bool remove(const ItemType& anEntry);

void clear();

bool contains(const ItemType& anEntry) const;

std::vector toVector() const;

}; // end ArraySet

//ArraySet.cpp

#include

template

ArraySet::ArraySet(): itemCount(0), maxItems(DEFAULT_CAPACITY)

{

} // end default constructor

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!