On the line

set<T>::iterator iter;

I am getting "expected ';' before 'iter'"

#include <vector>
#include <set>
using namespace std;
	template <typename T>
	vector<T> UniqueElements(const vector<T> &V)
	{
		set<T> s;
		s.insert(V.begin(), V.end());
		vector<T> Elements;
		
		set<T>::iterator iter;

		return Elements;
		
	}

Can anyone see why?

It compiles fine if I do

set<int>::iterator iter;

Thanks,
Dave

Ah I remember now, someone had shown me this once before:

typename set<T>::iterator it;

But we never understood why you had to do this? Can anyone explain?

see previous post :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.