Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE CODE IN C++: I have some of the code implemented but i keep getting the compilation error: fatal error: MySet.h: No such file or

PLEASE CODE IN C++:

I have some of the code implemented but i keep getting the compilation error: fatal error: MySet.h: No such file or directory

As well I am supposed to create a nested iterator class that supports the supports the end sentinel concept, but i'm not sure how to implement it.

Using the Standard C++ Library vector as an underlying implementation, create a Set template class that accepts only one of each type of object that you put into it. Make a nested iterator class that supports the end sentinel concept in Unit 16. Write test code for your Set in main(), using both your Set template class and the Standard C++ Library set template to verify that the behaviour is correct.

Code is below:

#include #include #include #ifndef MYSET_H #define MYSET_H

template

class MySet

{

public:

MySet();

~MySet();

inline bool insert(T insertObject)

{

for (int i=0; i< obj.size(); i++)

{

if (obj[i] == insertObject)

{

return false;

}

}

obj.push_back(insertObject);

return true;

}

typename std::vector::iterator begin()

{

typename std::vector::iterator it;

it = obj.begin();

return it;

}

typename std::vector::iterator end()

{

typename std::vector::iterator it;

it = obj.end();

return it;

}

private:

std::vector obj;

typename std::vector::iterator m_begin;

typename std::vector::iterator m_end;

};

template

MySet::MySet()

{

}

template

MySet::~MySet()

{

}

#endif

#include

#include "MySet.h"

#include

using namespace std;

int main()

{

MySet mySet;

mySet.insert(1);

mySet.insert(2);

mySet.insert(3);

mySet.insert(1);

MySet::iterator it = mySet.begin(); //ET LA IL AIME PAS !

vector::iterator it;

return 0;

}

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions