Could anyone explain why am I not able to use C++ templates like this:
template <typename T> class A {
public:
typedef std::vector<T>::iterator myiterator;
A(T value)
: v(10, value)
{
}
myiterator begin()
{
return v.begin();
}
myiterator end()
{
return v.end();
}
public:
std::vector<T> v;
};
int main()
{
A<int> a(10);
for (auto i = a.begin(); i != a.end(); ++i)
std::cout << *i << std::endl;
return 0;
}
I got the compilation error on the line where myiterator alias is declared; the error is: "missing ';' before identifier 'myiterator'".