首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

建立树的时候不能new一个孩子的数组解决思路

2012-03-30 
建立树的时候不能new一个孩子的数组#includeiostreamusingnamespacestd//typedefcharstructtree{chard

建立树的时候不能new一个孩子的数组
#include   <iostream>  
using   namespace   std;
//typedef   char;
struct   tree{
char   data;
tree   *rchild,*lchild,*newNode;
int   OP,total;                                                 //OP=层次   total表示孩子数目
//*char   children[10];
}T;
  void   CreateTree()
    {      
                    cin> > T.data;      
                    if(T.data== '       ')      
                    {      
                                  cout < < "请输入家族已知创始人 " < <endl;
  cin> > T.data;
                    }      
                    else      
                    {      
                                    cin> > T.total;      
                                  new   char   children[10];       //*************************
                                    for(int   i=0;i <T.total;i++)      
                                    {      
                                                        T.newNode-> children[i]       =       CreateTree();      
                                    }      
                      //               return       T.newNode;      
                    }    
//   ~CreatTree();
    }      
void   main()
{}


我想在获得一个节点的时候new一个关于他孩子的数组   但是不能new,   error   C2039:   'children '   :   is   not   a   member   of   'tree '
请问要怎么解决。。。在线等
.....

thx。。。。。。。。。。。。



[解决办法]
struct tree{
char data;
tree *rchild,*lchild,*newNode;
int OP,total; //OP=层次 total表示孩子数目
char* children;
}T;

children = new char[10];
[解决办法]
new char children[10];



改成

children = new char[10];

热点排行
Bad Request.