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
}; // end ArraySet
//ArraySet.cpp
#include
template
ArraySet
{
} // end default constructor
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