陶小童 2017-08-12 07:04 采纳率: 0%
浏览 1130

c++数据结构里面一直有无法解析,该函数在main函数里面被引用,该怎么解决,代码如下

错误如下
错误 LNK1120 8 个无法解析的外部命令 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\Debug\ConsoleApplication2.exe 1

错误 LNK2019 无法解析的外部符号 "public: bool __thiscall CriList::empty(void)" (?empty@?$CriList@H@@QAE_NXZ),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: class Node * __thiscall CriList::insert(int,int)" (?insert@?$CriList@H@@QAEPAV?$Node@H@@HH@Z),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: class Node * __thiscall CriList::search(int)" (?search@?$CriList@H@@QAEPAV?$Node@H@@H@Z),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: void __thiscall CriList::set(int,int)" (?set@?$CriList@H@@QAEXHH@Z),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: __thiscall CriList::CriList(int * const,int)" (??0?$CriList@H@@QAE@QAHH@Z),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: int __thiscall CriList::count(void)" (?count@?$CriList@H@@QAEHXZ),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

错误 LNK2019 无法解析的外部符号 "public: int __thiscall CriList::get(int)" (?get@?$CriList@H@@QAEHH@Z),该符号在函数 _main 中被引用 ConsoleApplication2 E:\数据结构与算法暑假\ConsoleApplication2\ConsoleApplication2\main.obj 1

#include"head.h"
int main()
{
Nodenode(5);
int values[9] = { 1,2,3,4,5,7,8,9 };
CriList cl(values, 9);
if (cl.empty())
{
cout << "不为空" << endl;
}
else
{
cout << "空" << endl;
}
cout << "长度为:" << cl.count() << endl;
cout << "在3号位置的是" << cl.get(3) << endl;
cout << "把5号位置的数据替换为10" << endl;
cl.set(5, 10);
cout << "把5号位置插入为12" << endl;
cl.insert(5, 12);
cl.removeAll();
cout << "查找数据为11的数" << endl;
cl.search(11);
return 0;

}
//fun。cpp
#include"head.h"
template
CriList::CriList()//创建一个空表
{
this->head = new Node();
this->head->next = this->head;
}
template
CriList::CriList(T values[], int n)
{
int i = 0;
head = new Node();
Node*p = head;
while (i < n)
{
Node*q = new Node();
q->data = values[i];
q->next=NULL;
p->next = q;
p = q;
}
p->next = head;
printf();
}
template
bool CriList::empty()
{
return this->head->next = this->head;
}
template
int CriList::count()
{
int i = 0;
Node*q = head;
while (q->next != head)
{
i++;
}

return i;

}
template
T CriList::get(int i)
{
int j;
Nodep = head;
for(j=0;jnext!=head;j++)
{
p = p->next;
}
if (j == i)
{
return this->head->data;
}
}
template
void CriList::set(int i, T x)
{
int j;
Node*p = this->head;
for (j = 0; jnext!=head;j++)
{
p = p->next;
}
if (j == i)
{
p->data = x;
}
printf();
}
template
void CriList::printf()
{
Node*p = this->head;
while (p->next! = head)
{
cout << p->data << '\t';
}
}
template
Node
CriList::insert(int i, T x)
{
int j;
Node*p = this->head;
for (j = 0; jnext != head; j++)
{
p = p->next;
}
if (j == i)
{
Node*q = new Node();
q->data = x;
q->next = p->next;
p->next = q;
}
}
template
void CriList::removeAll()
{
Node*q = head;
while (q->next != head)
{
Node*p = new Node();
p = q->next;
delete p;
p = p->next;
}
}
template
Node*CriList::search(T key)
{
Node*q = head;
while (q->next!= head)
{
q = q->next;
if (q->data == key)
{
cout << "查找正确" < }
}
if (q->next == head)
{
cout << "查找失败" << endl;
}
}
//head.h
#include
using namespace std;
template
class Node
{
public:
T data;
Node*next;//指针域分别指向后继结点。
Node()//构造结点,data域未初始化无参构造函数
{
this->next = NULL;
}
Node(T data, Node*next = NULL)//有参构造函数,后继结点默认值为空
{
this->data = data;
this->next = next;
}
};
template
class CriList
{
public:
Node*head;//头指针
CriList();//构造空表
CriList(T values[], int n);
bool empty();//判断是否为空表
int count();//返回链表的长度
T get(int i);//返回第i个元素
void set(int i, T x);//设置第i个元素为X,虚函数
void printf();//输出循环链表
Node*insert(int i, T x);//插入x作为第i个元素
void removeAll();//清空循环链表
Node*search(T key);//查找关键字位key的元素
};

  • 写回答

5条回答

  • 喵小白521 2017-08-12 07:41
    关注

    不理解你想问的问题是什么

    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效