B
bite
Anybody could tell me what is wrong with these few lines of code?
#include <map>
#include <vector>
template<class Key, class Value>
#include <map>
#include <vector>
template<class Key, class Value>
class PointerVector : public std::vector<Value *>
{
public:
PointerVector () {}
PointerVector (std::map<Key, Value> & as) : std::vector<Value *>
(as.size ())
{
int i = 0;
std::map<Key, Value>::iterator it;
for (it = as.begin ();
it != as.end ();
it++) {
(*this) = &it->second;
i++;
}
}
virtual ~PointerVector () {}
};
I get " error: expected `;' before ‘it’" at line 12 (declaring the
iterator) when compiling with g++ 4.2.4
#include <map>
#include <vector>
template<class Key, class Value>
#include <map>
#include <vector>
template<class Key, class Value>
class PointerVector : public std::vector<Value *>
{
public:
PointerVector () {}
PointerVector (std::map<Key, Value> & as) : std::vector<Value *>
(as.size ())
{
int i = 0;
std::map<Key, Value>::iterator it;
for (it = as.begin ();
it != as.end ();
it++) {
(*this) = &it->second;
i++;
}
}
virtual ~PointerVector () {}
};
I get " error: expected `;' before ‘it’" at line 12 (declaring the
iterator) when compiling with g++ 4.2.4