您所在的位置:Seago-Microsoft Windows>>Windows管理脚本>> 一个C 的问题,请高手指点!

一个C 的问题,请高手指点!

作者:menface 来源:新浪爱问 日期:2008-04-24 

请高手指点:
我把节点的定义放在9_5.h中,把链表的定义放在9_6.h中,把链表的应用放在9_7.cpp中,不过在编译的时候总出问题,问题如下:
--------------------Configuration: 9_7 - Win32 Debug--------------------
Compiling...
9_7.cpp
e:\wzhgxp\last material\studying\first\9_5.h(12) : error C2629: unexpected 'class Node<T> ('
e:\wzhgxp\last material\studying\first\9_5.h(16) : see reference to class template instantiation 'Node<T>' being compiled
e:\wzhgxp\last material\studying\first\9_5.h(12) : error C2238: unexpected token(s) preceding ';'
e:\wzhgxp\last material\studying\first\9_5.h(16) : see reference to class template instantiation 'Node<T>' being compiled
e:\wzhgxp\last material\studying\first\9_5.h(19) : error C2039: '__ctor' : is not a member of 'Node<T>'
e:\wzhgxp\last material\studying\first\9_5.h(19) : error C2935: 'Node<T>' : template-class-id redefined as a global function
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2143: syntax error : missing ';' before '*'
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2936: 'Node<`template-parameter257'>' : template-class-id redefined as a global data variable
e:\wzhgxp\last material\studying\first\9_5.h(19) : see declaration of 'Node<`template-parameter257'>'
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2501: 'Node<`template-parameter257'>' : missing storage-class or type specifiers
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2373: 'Node<`template-parameter257'>' : redefinition; different type modifiers
e:\wzhgxp\last material\studying\first\9_5.h(19) : see declaration of 'Node<`template-parameter257'>'
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2059: syntax error : ';'
e:\wzhgxp\last material\studying\first\9_5.h(23) : error C2065: 'T' : undeclared identifier
e:\wzhgxp\last material\studying\first\9_5.h(28) : error C2954: template definitions cannot nest
e:\wzhgxp\last material\studying\first\9_5.h(29) : error C2061: syntax error : identifier 'Node<`template-parameter257'>'
e:\wzhgxp\last material\studying\first\9_5.h(33) : error C2244: 'Node<T>::InsertAfter' : unable to resolve function overload
e:\wzhgxp\last material\studying\first\9_5.h(35) : error C2954: template definitions cannot nest
e:\wzhgxp\last material\studying\first\9_5.h(36) : error C2143: syntax error : missing ';' before '*'
e:\wzhgxp\last material\studying\first\9_5.h(36) : error C2936: 'Node<`template-parameter257'>' : template-class-id redefined as a global data variable
e:\wzhgxp\last material\studying\first\9_5.h(19) : see declaration of 'Node<`template-parameter257'>'
e:\wzhgxp\last material\studying\first\9_5.h(36) : error C2501: 'Node<`template-parameter257'>' : missing storage-class or type specifiers
e:\wzhgxp\last material\studying\first\9_5.h(36) : error C2373: 'Node<`template-parameter257'>' : redefinition; different type modifiers
e:\wzhgxp\last material\studying\first\9_5.h(19) : see declaration of 'Node<`template-parameter257'>'
e:\wzhg
附件:程序.rar 电脑问题网给出的最佳答案 构造函数设置默认值应该是一个等号,你写的是两个
Node(const T&item,Node<T>* ptrnext==NULL);
改成Node(const T&item,Node<T>* ptrnext=NULL);
另外应该把所有的文件放在同一个工作区里,这样出错应该少一点,就是选中Project->add to project->files,选中要使用的头文件和cpp文件.
我将你的程序调通了,如果没讲清楚可以给我发消息

上一篇:vb 登录框的制作   下一篇:PASCAL问题