This school project accepts integers into a custom data type called "set". Set is a list that accepts and manipulates integers. This is my first time using templates. The code will compile perfectly in Dev C++ but not visual studio 2010 express. My error codes are at the bottom. (I also have an application file that has been omitted since all of the errors are in the .template file.)
Thanks for your help.
#include <iostream>
#include <cmath>
#include <cassert>
#include <list>
#include <iterator>
#include <algorithm>
usingnamespace std;
namespace Swirly_Stem
{
std::list<int>::iterator iter;
template <class T>
bool set<T>::erase_one(const T& target)
{
value_type index;
index = 0;
for(iter=data.begin();iter!=data.end();++iter)
{
if (iter == data.end())
{
returnfalse;
}
}
data.erase(iter);
//i would use pop back but this handles the erase from the center too.
returntrue;
};
template<class T>
void set<T>::insertation2(const T& entry)
{
data.push_back(entry);//first in is last data element.
data.unique();//This enforces all data to be unique
}
template<class T>
bool set<T>::contains2(const T& entry)
{
size_type i=0;
bool returner = true;
return returner;
}
}
You have a few semicolons in the middle of nowhere, your list should be public. Your erase_one never erases anything and doesn't do anything with the value it has been passed to. None of your methods work with anything except set<int>, and quite frankly I have absolutely no idea why your set is a template, as you never do anything with the type parameter.