设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 840|回复: 1
打印 上一主题 下一主题

[求助]错在那?

[复制链接]
跳转到指定楼层
1#
发表于 2009-11-4 00:49:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这代码能编译通过,但是连接时有错误,请大虾帮我看一下!谢谢了!
#ifndef NODE_CLASS
#define NODE_CLASS
template <class T>
class Node
{
private :
Node <T> *next;
public:
T DaTA;
Node (const T &item,Node <T> *ptrnext=NULL);
void InsertAfter(Node <T> *p);
Node <T> *DeleteAfter (void );
Node <T> *NextNode (void )const;
};

template <class T>
Node <T> ::Node (const T &item,Node <T> *ptrnext):data(item),next(ptrnext){}
template <class T>
Node <T> *Node <T>::NextNode (void) const
{return next;}
template <class T>
void Node <T>::InsertAfter(Node <T> *p)
{p->next=next;
next=p;
}
template <class T>
Node<T> *Node <T>::DeleteAfter(void)
{Node<T> *tempPtr=next;
if(next==NULL)
return NULL;
next=tempPtr->next;
return tempPtr;
}
#endif
#ifndef LINKEDLIST_CLASS
#define LINKEDLIST_CLASS
#include <iostream>
#include <cstdlib>
using namespace std;
#ifndef NULL
const int NULL=0;
#endif
template <class T>
class LinkedList
{private :
Node <T> *front,*rear;
Node <T> *prevPtr,*currPtr;
int size ;
int position;
Node<T> *GetNode (const T &item,Node<T> *ptrNext=NULL);
void FreeNode (Node <T> *p);
void CopyList(const LinkedList<T> &L);
public:
LinkedList( void );
LinkedList(const LinkedList<T> &L);
~LinkedList(void );
LinkedList<T> &operator =(const LinkedList <T> &L);
int ListSize(void )const;
int ListEmpty(void) const;
void Reset (int pos=0);
void Next(void );
int EndOfList(void) const;
int CurrentPosition(void) const;
void InsertFront(const T& item);
void InsertRear(const T &item);
void InsertAt(const T &item);
void InsertAfter(const T &item);
T DeleteFront(void );
void DeleteAt(void );
T &Data(void);
void ClearList(void);
};
#endif
#include<iostream>

using namespace std;
void main()
{LinkedList <int > Link;
int i,key,item;
for(i=0;i<10;i++)
{cin>>item;
Link.InsertFront(item);
}
cout<<"List:"<<endl;
Link.Reset();
while(!Link.EndOfList())
{ cout<<Link.Data()<<" ";
Link.Next();
}
cout<<endl;
cout<<" Enter the number you want to delete :"<<endl;
cin>>key;
Link.Reset();
while(!Link.EndOfList())
{if(Link.Data()==key)
Link.DeleteAt();
Link.Next();
}
cout<<"List:"<<endl;
Link.Reset();
while(!Link.EndOfList())
{cout<<Link.Data()<<" ";
Link.Next();
}
cout<<endl;
}
连接时的错误:
-----------------Configuration: 3333 - Win32 Debug--------------------
Linking...
3333.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<int>::~LinkedList<int>(void)" (??1?$LinkedList@H@@QAE@XZ)
3333.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<int>::DeleteAt(void)" (?DeleteAt@?$LinkedList@H@@QAEXXZ)
3333.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<int>::Next(void)" (?Next@?$LinkedList@H@@QAEXXZ)
3333.obj : error LNK2001: unresolved external symbol "public: int & __thiscall LinkedList<int>::Data(void)" (?Data@?$LinkedList@H@@QAEAAHXZ)
3333.obj : error LNK2001: unresolved external symbol "public: int __thiscall LinkedList<int>::EndOfList(void)const " (?EndOfList@?$LinkedList@H@@QBEHXZ)
3333.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<int>::Reset(int)" (?Reset@?$LinkedList@H@@QAEXH@Z)
3333.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<int>::InsertFront(int const &)" (?InsertFront@?$LinkedList@H@@QAEXABH@Z)
3333.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<int>::LinkedList<int>(void)" (??0?$LinkedList@H@@QAE@XZ)
Debug/3333.exe : fatal error LNK1120: 8 unresolved externals
?′DD link.exe ê±3?′í.
3333.exe - 1 error(s), 0 warning(s)
2#
发表于 2009-11-4 00:49:15 | 只看该作者
老兄:

你的那个类没有定义啊!!!!!!!!!!!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 21:38 , Processed in 0.086732 second(s), 9 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表