当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·怎样作才能实现form自动提交    »显示摘要«
    摘要: 看程序: ... <table> <form action=.. method=post> <tr> <td><input type=text name=user></td> </tr> <tr> <td><input type=password name=pass>&l......
    摘要: 同上 ......


如何动态分配生成结构数组

struct     student  
  {  
  char   name[8];  
  char   sex[2];  
  int   num;  
  };  
   
  student     stu[3];       //还是用student*   stu[3];为什么?  
  for(int   i=0;   i<3;   i++)  
          stu[i]   =   new   student;  
  stu[0]->num   =   0;  
 

NO.1   作者: qhgary

为什么?因为你需要的是一个指针数组,也就是说str[0],str[1],str[2]都是指针

struct     student  
  {  
  char   name[8];  
  char   sex[2];  
  int   num;  
  };  
   
  student     *   stu[3];        
  for(int   i=0;   i<3;   i++)  
          stu[i]   =   new   student;  
  stu[0]->num   =   0;  
   
  new   student返回的是一个指针  
 

NO.3   作者: ambition2005

new返回的是指针  
  所以****  
  我刚开始学NEW时,也搞错过  
  呵呵

NO.4   作者: webmelon

是student     *stu[3];      
  实际上定义一个对象指针。

NO.5   作者: cenphoenix

应该是student     *stu[3];      
  如果你用student     stu[3];的话,那你就要这样了:stu[0].num   =   0;


    摘要: 请问如何在没有安装pb8.0和oracle817的电脑上运行pb8.0+oracle817编写的程序???需要哪些目录下的哪些动态库? ......
» 本期热门文章:
· 热门栏目:
» 相关精选文章
» 其它相关:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE