I am getting a compilation error:
HuffTree.cpp:43:20: error: ‘SIZE’ cannot appear in a constant-expression
PQueue<HuffNode*, SIZE>;
where the involved lines are:
void HuffTree::buildTree(char * chs, int * freqs, int size )
{
static const int SIZE = size;
PQueue<HuffNode*, SIZE>;
I've tried all different types for "SIZE"
PQueue<HuffNode*, size>; // From the method parameter
static const int SIZE = static_cast<int>(size);
etc. But the only the following compiles:
PQueue<HuffNode*, 10>; // Or any other random int
I also get the related error:
HuffTree.cpp:43:24: error: template argument 2 is invalid
PQueue<HuffNode*, SIZE>;
PQueue is a template class accepting:
template< class T, int MAX_SIZE >
PQueue(T* items, int size);
What type does 'size' need to be for the argument to be accepted?
Using c++11
Aucun commentaire:
Enregistrer un commentaire