Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions