#include <vector>
#include <cstdlib>
#include "huffman.h"
#include "bitbuf.h"
using std::vector;
template <typename T>
HuffmanTree<T>::HuffmanTree(const vector<HuffmanNode<T>*>& node_list)
{
//ERRORS HERE
vector<HuffmanNode<T>*>::const_iterator iter;
iter = node_list.begin();
while(iter != node_list.end())
add(iter->token,iter->token_freq);
}
//more code...
The errors are:
...huffman_tree.cpp: In constructor `HuffmanTree<T>::HuffmanTree(const std::vector<HuffmanNode<T>*, std::allocator<HuffmanNode<T>*> >&)': ...huffman_tree.cpp:11: error: expected `;' before "iter" ...huffman_tree.cpp:12: error: `iter' undeclared (first use this function) ...huffman_tree.cpp:12: error: (Each undeclared identifier is reported only once for each function it appears in.)
I'm using GCC on Cygwin for Windows (against my better judgment, I might add). I've tried inserting using namespace std as well as various combinations of prefixing std:: and even including iterator, though I've never had to before. Any ideas?
EDIT: I think I have to dereference iter again in the loop ( (*iter)->token instead of iter->token ), but that's not what's giving me the error.


Sign In
Create Account

Back to top











