| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 496 人关注过本帖
标题:[求助]错在那?
只看楼主 加入收藏
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
收藏
 问题点数:0 回复次数:1 
[求助]错在那?

这代码能编译通过,但是连接时有错误,请大虾帮我看一下!谢谢了!
#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
Ö´ÐÐ link.exe ʱ³ö´í.

3333.exe - 1 error(s), 0 warning(s)

2006-10-29 11:00
lengfei6297
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-10-30
收藏
得分:0 

老兄:

你的那个类没有定义啊!!!!!!!!!!!!!

2006-10-30 22:21
快速回复:[求助]错在那?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029546 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved