Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING C++ Set Class (required): A set class is used to represent sets of integers. It supports most of the standard set operations. Write a

USING C++

Set Class (required):

A set class is used to represent sets of

integers. It supports most of the standard set operations.

Write a template-based class that implements a set of items. A set is collection of items in

which no item occurs more than once. Internally, you may represent the set using the data

structure of your choice (list, vector, arrays, etc.). However, the class should externally

support the following functions:

Set data structure:

A set is a collection of objects need not to be in any particular order. Elements

Sample class declaration:

-

You class should have all of the followings.

-

Can be defined as friend functions

class

Set {

public

:

//default constructor

Set();

//add element to set

void

addElement (

int

element);

//remove element from set

void

removeElement(

int

element);

//check for membership

-

bool

isMember(

int

element);

//set union, modifies curremtn set

void

Union (Set s);

//set difference modifiers current set

void

difference (Set s);

//size of set

int

size();

//get element i

int

getElement (

int

i);

//Return a pointer to a dynamically created array containing each item in the set.

//The caller of this function is responsible for deallocating the memory.

private

:

...

...

...

};

Test your class by creating different sets of different data types (for examples, strings,, integers,

or other classes). If you add objects to your set, then you may need to overload the = = and !=

operators for the objects class so your template-based set class can properly determine

membership.

?

A suitable overloading of the quality operator ==

?

A suitable overloading of the inquality operator !=

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago

Question

1. How did you go about making your selection?

Answered: 1 week ago