读书人

Huffman树的一段代码不知道错哪了

发布时间: 2012-09-28 00:03:35 作者: rapoo

Huffman树的一段代码,不知道哪里错了请指教
Huffman树的一段代码,修改过便于发贴

C/C++ code
#include <stdio.h>#include <vector>using namespace std;struct HuffmanNode{    int weight;    int isLeaf;    struct HuffmanNode *parent;    bool isUsed;};typedef struct HuffmanNode HNode;vector<HNode*> myQueue;int main(){;    int weight=0;    for(int i=0;i<5;i++){                HNode *hNode;        hNode->weight=weight;        hNode->isLeaf=true;        hNode->isUsed=false;        hNode->parent=NULL;        myQueue.push_back(hNode);    }    printf("queue size:%d\n",myQueue.size());    return 0;}


用g++编译,但老是就报个segmantaion fault 不知所云啊,还请各位给看下!

[解决办法]
int main(){
;//这里怎么有个;
int weight=0;

[解决办法]
HNode *hNode; 是个指针 得new 申请空间

读书人网 >C++

热点推荐