提示:error LNK2001: 无法解析的外部符号 "class Linklist link" (?link@@3VLinklist@@A)解决方法
提示:error LNK2001: 无法解析的外部符号 "class Linklist link" (?link@@3VLinklist@@A)
郁闷啊,还不容易写好了链表,结果运行时出来这么个提示,找了下好像是说程序有问题,但是看来看去都没找到啊,求大神帮助啊!![code=C/C++][/code]#include "stdafx.h"
#include"linklist.h"
Linklist::Linklist()
{
head=new node;
head->next=NULL;
}
node* Linklist::find(CString a)
{
node *p;
for(p=head->next;p!=NULL;p=p->next)
{
if(p->num==a) return p;
}
return p;
}
node* Linklist::find(CString a,CString b)
{
node *p;
for(p=head->next;p!=NULL;p=p->next)
{
if(p->name==b) return p;
}
return p;
}
bool Linklist::add(CString a, CString b)
{
node *p=find(a);
if(p!=NULL) return 0;
else
{
node *q=new node;
q->next=head->next;
head->next=q;
q->num=a;
q->name=b;
return 1;
}
}
bool Linklist::add(CString a, CString b,CString c)
{
node *p=find(a);
if(p!=NULL) return 0;
else
{
node *q=new node;
q->next=head->next;
head->next=q;
q->num=a;
q->name=b;
q->photo=c;
return 1;
}
}
bool Linklist::del(CString a)
{
node *p,*q;
for(p=head->next,q=head;p!=NULL;p=p->next,q=q->next)
{
if(p->num==a)
{
q->next=p->next;
delete p;
return 1;
}
}
return 0;
}
bool Linklist::del(CString a, CString b)
{
node *p,*q;
for(p=head->next,q=head;p!=NULL;p=p->next,q=q->next)
{
if(p->name==b)
{
q->next=p->next;//MessageBox(NULL,_T("ok"),_T("ok"),MB_ICONWARNING);
delete p;
return 1;
}
}
return 0;
}
bool Linklist::change(CString a, CString b, CString c)
{
node *p=find(a);
if(p==NULL) return 0;
else
{
p->num=a;
p->name=b;
p->photo=c;
return 1;
}
}
[code=C/C++][/code]struct node
{
CString num,name,photo;
node *next;
};
class Linklist
{
private:
node *p;
public:
node *head;
Linklist();
bool add(CString a,CString b);
bool add(CString a,CString b,CString c);
bool del(CString a);
bool del(CString a,CString b);
node* find(CString a);
node* find(CString a,CString b);
bool change(CString a,CString b,CString c);
};
[code=C/C++][/code]// bhtDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "bht.h"
#include "bhtDlg.h"
#include "linklist.h"
extern Linklist link;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的CAboutDlg 对话框
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CbhtDlg 对话框
CbhtDlg::CbhtDlg(CWnd* pParent /*=NULL*/)
: CDialog(CbhtDlg::IDD, pParent)
, t_num(_T(""))
, t_photo(_T(""))
, t_name(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CbhtDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, t_num);
DDV_MaxChars(pDX, t_num, 100);
DDX_Text(pDX, IDC_EDIT3, t_photo);
DDX_Text(pDX, IDC_EDIT2, t_name);
郁闷啊,还不容易写好了链表,结果运行时出来这么个提示,找了下好像是说程序有问题,但是看来看去都没找到啊,求大神帮助啊!![code=C/C++][/code]#include "stdafx.h"
#include"linklist.h"
Linklist::Linklist()
{
head=new node;
head->next=NULL;
}
node* Linklist::find(CString a)
{
node *p;
for(p=head->next;p!=NULL;p=p->next)
{
if(p->num==a) return p;
}
return p;
}
node* Linklist::find(CString a,CString b)
{
node *p;
for(p=head->next;p!=NULL;p=p->next)
{
if(p->name==b) return p;
}
return p;
}
bool Linklist::add(CString a, CString b)
{
node *p=find(a);
if(p!=NULL) return 0;
else
{
node *q=new node;
q->next=head->next;
head->next=q;
q->num=a;
q->name=b;
return 1;
}
}
bool Linklist::add(CString a, CString b,CString c)
{
node *p=find(a);
if(p!=NULL) return 0;
else
{
node *q=new node;
q->next=head->next;
head->next=q;
q->num=a;
q->name=b;
q->photo=c;
return 1;
}
}
bool Linklist::del(CString a)
{
node *p,*q;
for(p=head->next,q=head;p!=NULL;p=p->next,q=q->next)
{
if(p->num==a)
{
q->next=p->next;
delete p;
return 1;
}
}
return 0;
}
bool Linklist::del(CString a, CString b)
{
node *p,*q;
for(p=head->next,q=head;p!=NULL;p=p->next,q=q->next)
{
if(p->name==b)
{
q->next=p->next;//MessageBox(NULL,_T("ok"),_T("ok"),MB_ICONWARNING);
delete p;
return 1;
}
}
return 0;
}
bool Linklist::change(CString a, CString b, CString c)
{
node *p=find(a);
if(p==NULL) return 0;
else
{
p->num=a;
p->name=b;
p->photo=c;
return 1;
}
}
[code=C/C++][/code]struct node
{
CString num,name,photo;
node *next;
};
class Linklist
{
private:
node *p;
public:
node *head;
Linklist();
bool add(CString a,CString b);
bool add(CString a,CString b,CString c);
bool del(CString a);
bool del(CString a,CString b);
node* find(CString a);
node* find(CString a,CString b);
bool change(CString a,CString b,CString c);
};
[code=C/C++][/code]// bhtDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "bht.h"
#include "bhtDlg.h"
#include "linklist.h"
extern Linklist link;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的CAboutDlg 对话框
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CbhtDlg 对话框
CbhtDlg::CbhtDlg(CWnd* pParent /*=NULL*/)
: CDialog(CbhtDlg::IDD, pParent)
, t_num(_T(""))
, t_photo(_T(""))
, t_name(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CbhtDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, t_num);
DDV_MaxChars(pDX, t_num, 100);
DDX_Text(pDX, IDC_EDIT3, t_photo);
DDX_Text(pDX, IDC_EDIT2, t_name);