陶小童 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 有卷积神经网络识别害虫的项目吗
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件