iterator undeclared error?
Hi,
I can create a vector. I need an iterator so I can index the vector I have created. However, I get an error "Iterator undeclared" when I do this. What is missing?
Code:
#include <vector>
#include <iterator>
. . .
header.num_vertices=200;
std::vector<VERTEX> v;
v.resize(header.num_vertices);
std::iterator idx;
idx=v.begin();
VERTEX is a structure of x,y and z floats.
Regards,
ChuckB
Re: iterator undeclared error?
Quote:
Originally posted by ChuckB
Code:
...
std::vector<VERTEX> v;
v.resize(header.num_vertices);
std::vector<VERTEX>::iterator idx;
idx=v.begin();
The iterator is an inner class of the container. Create them like the above. In many cases, you can typedef them, as well:
Code:
class myClass
{
public:
std::vector<int> x;
typedef std::vector<int>::iterator vec_it;
};
And just use vec_it as the type.
Z.