我知道typedef的一般用途,但是在这里就搞不明白了.typedef struct node{
  int data;
  struct node next;
}NODE;

解决方案 »

  1.   

    一般格式,这样容易让人理解,不过
              struct node next;
    这样好像定义的不是链表
      

  2.   

    in C, u should use 
     struct node n1;
    to define a variable has node type,though u can omit the frontal 'struct' in c++.in this case, using 'NODE' instead of 'struct node' can simplify the declare of a variable.
      

  3.   

    其实不加这么一句也可以的,不过数据结构课本上都是这么写的.说是这样定义以后,node就是一种类型了,就像int, bool一样,定义node类型的对象了.
      

  4.   

    modify:
       struct node next;-->struct node *next;
      

  5.   

    那也不对呀,typedef的一般格式是:
      
      typedef type newname;
     
      //type 是合法的数据类型, newname是新名字.这样一来上面程序应该是错误的啊?
      

  6.   

    struct node{...}就是type,NODE是newname
      

  7.   

    C语言时就有。
    typedef用于定义自己的类型,就是把struct node 定义成NODE类型。
    这样以后你在定义时就不用写struct node newnode;了,可以直接写成NODE newnode;
    你还可以这样定义:
    struct node {
    ......
    }NODE,*pNODE;
    等等。 
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]