源码:(vs2015)
#include
using namespace std;
//节点类(抽象类)
template
class HuffNode
{
public:
HuffNode(){}
virtual ~HuffNode() {}
virtual int weight() = 0;
virtual bool isLeaf() = 0;
};
//叶节点类(继承自节点类)
template
class LeafNode :pulic HuffNode
{
private:
E it;
int wgt;
public:
//构造叶节点
LeafNode(const E& val, int freq)
{
it = val;
wgt = freq;
}
//返回该叶节点的权值
int weight()
{
return wgt;
}
//返回节点的值
E val()
{
return it;
}
//判断是否是叶节点
bool isLeaf()
{
return true;
}
};
错误报告:
1>------ 已启动生成: 项目: Huffman编码, 配置: Debug Win32 ------
1> main.cpp
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(14): error C2988: 不可识别的模板声明/定义
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(14): error C2143: 语法错误: 缺少“;”(在“<”的前面)
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(14): error C2059: 语法错误:“<”
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(15): error C2143: 语法错误: 缺少“;”(在“{”的前面)
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(15): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>c:\users\asus\desktop\huffman编码\huffman编码\huffman.h(25): error C2143: 语法错误: 缺少“,”(在“”的前面)