0

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

1
Contributor
2
Replies
3
Views
8 Years
Discussion Span
Last Post by daviddoria
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.