Hi guys,
The following code doesn't compile, and I've been banging my head why. Some header code:
template <typename T, typename LESS_THAN>
class RestrictedSet
{
private :
int _size;
int _max_size;
set<T, LESS_THAN> _S;
typedef typename std::set<T, LESS_THAN>::iterator tIt;
public :
RestrictedSet (int max_size);
RestrictedSet (RestrictedSet<T, LESS_THAN> &other);
~RestrictedSet ();
void insert (T &elem);
T pop_best ();
void drop_worst ();
void show ();
};
And some .cpp code:
template <typename T, typename LESS_THAN>
void RestrictedSet::insert (const T elem)
{
_S.insert (elem);
if (++_size > _max_size) drop_worst();
}
The problem must be somewhere in the template part, I get the error:
agenda.cpp:28: error: ‘template<class T> class RestrictedSet’ used without template parameters
agenda.cpp:28: error: variable or field ‘insert’ declared void
agenda.cpp:28: error: expected nested-name-specifier before ‘T’
agenda.cpp:28: error: expected ‘(’ before ‘T’
I also tried variants like:
void <T, LESS_THAN> RestrictedSet::insert (const T elem)
Hope someone can help!