error C2440: '=' : cannot convert from 'int' to 'struct HuffmanNode *'
Conversionfromintegraltypetopointertyperequiresreinterpret_cast,C-stylecastorfunction...
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
错误出现在这几行:
HuffTree[x1].parent=n+i;
HuffTree[x2].parent=n+i;
HuffTree[x1].flag=1;
HuffTree[x2].flag=1;
HuffTree[n+i].weight=HuffTree[x1].weight+HuffTree[x2].weight;
HuffTree[n+i].leftChild=x1;
HuffTree[n+i].rightChild=x2;
我的结构体是这样定义的:
struct HuffmanNode
{
int weight;
char character;
bool isLeaf;
int flag;
int createSort; //用于标记节点创建顺序
int position; //用于记录节点在树中的位置。以完全二叉树计算的
POINT nodePt; //节点坐标,用于绘图
HuffmanNode *selfAddress;//存储自身地址
HuffmanNode *leftChild,*rightChild,*parent;
HuffmanNode(int elem,HuffmanNode* left = NULL, HuffmanNode* right = NULL, HuffmanNode* ptr = NULL ):weight(elem),
leftChild(left), rightChild(right), parent(ptr){}
bool operator <=(HuffmanNode& R){return weight <= R.weight;}
bool operator > (HuffmanNode& R){return weight > R.weight;}
};
求大神帮忙解决 展开
错误出现在这几行:
HuffTree[x1].parent=n+i;
HuffTree[x2].parent=n+i;
HuffTree[x1].flag=1;
HuffTree[x2].flag=1;
HuffTree[n+i].weight=HuffTree[x1].weight+HuffTree[x2].weight;
HuffTree[n+i].leftChild=x1;
HuffTree[n+i].rightChild=x2;
我的结构体是这样定义的:
struct HuffmanNode
{
int weight;
char character;
bool isLeaf;
int flag;
int createSort; //用于标记节点创建顺序
int position; //用于记录节点在树中的位置。以完全二叉树计算的
POINT nodePt; //节点坐标,用于绘图
HuffmanNode *selfAddress;//存储自身地址
HuffmanNode *leftChild,*rightChild,*parent;
HuffmanNode(int elem,HuffmanNode* left = NULL, HuffmanNode* right = NULL, HuffmanNode* ptr = NULL ):weight(elem),
leftChild(left), rightChild(right), parent(ptr){}
bool operator <=(HuffmanNode& R){return weight <= R.weight;}
bool operator > (HuffmanNode& R){return weight > R.weight;}
};
求大神帮忙解决 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询