Try typename:
template <class T>
class CSafeSet
{
public:
CSafeSet();
~CSafeSet();
typename std::set<T>::iterator Begin();
private:
std::set<T> _Set;
};
You need typename there because it is dependent on the template T. More information in the link above the code. Lot's of this stuff is made easier if you use typedef's:
template <class T>
class CSafeSet
{
public:
typedef T value_type;
typedef std::set<value_type> container_type;
typedef typename container_type::iterator iterator_type;
typedef typename container_type::const_iterator const_iterator_type;
CSafeSet();
~CSafeSet();
iterator_type Begin();
private:
container_type _Set;
};
On a side note, if you want to be complete you need to allow CSafeSet to do the same thing as a set could, which means using a custom comparer and allocator:
template <class T, class Compare = std::less<T>, class Allocator = std::allocator<T> >
class CSafeSet
{
public:
typedef T value_type;
typedef Compare compare_type;
typedef Allocator allocator_type;
typedef std::set<value_type, compare_type, allocator_type> container_type;
typedef typename container_type::iterator iterator_type;
typedef typename container_type::const_iterator const_iterator_type;
// ...
}
And a last bit of advice, if you are going to create a wrapper around a class, try to follow the same naming conventions as where the class came from. That is, your Begin()
should probably be begin()
(And personally I think C before a class name is strange but that one is up to you :])