我想用两个队列层序建立二叉树 但是直接无法运行
class MyBinaryTreeNode{
public:
typedef struct BiTNode{
char data;
struct BiTNode*leftchild,*rightchild;
}BiTNode;
BiTNode* BuildBiT(string x){
BiTNode *T = new BiTNode();
queue<char>qd;
queue<BiTNode*>qT;
qT.push(T);
int length = sizeof x / sizeof (x[1]) ;
int numbers = 1;
for(int i = 0;i<length;i++){
qd.push(x[0]);
}
while(qd.size()!=0) {
if (numbers + 1 < length) {
if (qd.front() == '#') {
qd.pop();
qT.front() = NULL;
qT.pop();
} else {
qT.front()->data = qd.front();
qd.pop();
BiTNode *a = (BiTNode *) malloc(sizeof(BiTNode *));
qT.front()->leftchild = a;
BiTNode *b = (BiTNode *) malloc(sizeof(BiTNode *));
qT.front()->rightchild = b;
qT.pop();
numbers += 2;
}
}
else if (numbers + 1 == length) {
if (qd.front() == '#') {
qd.pop();
qT.front() = NULL;
qT.pop();
}
else {
qT.front()->data = qd.front();
qd.pop();
BiTNode *a = (BiTNode *) malloc(sizeof(BiTNode *));
qT.front()->leftchild = a;
qT.push(qT.front()->leftchild);
qT.pop();
numbers++;
}
}
else {
if (qd.front() == '#') {
qd.pop();
qT.front() = NULL;
qT.pop();
} else {
qT.front()->data = qd.front();
qd.pop();
qT.pop();
}
}
}
return T;
}
};