C++执行出现问题error LNK2001: unresolved external symbol "int __cdecl Front(struct SeQueue)

来源:百度知道 编辑:UC知道 时间:2024/06/27 08:31:38
#include"stdio.h"
#include"stdlib.h"
#define MAXSIZE 100
#define ElemType int
typedef struct
{ ElemType elem[MAXSIZE];
int front,rear;
}SeQueue;
SeQueue Q,h;
ElemType Front(SeQueue qq);
void creat(SeQueue *Q);
void insert(SeQueue *Q,ElemType x);
ElemType Delete(SeQueue *Q);
void main()
{ElemType y,x;
int cord;
do{ printf("\n");
printf("\n 主菜单\n");
printf(" 1 建立链表队列 \n");
printf(" 2 入队一个元素 \n");
printf(" 3 出对一个元素 \n");
printf(" 4 结束程序运行 \n");
printf("------------------\n");
printf("请选择(1,2,3,4)"); scanf("%d",&cord);
switch(cord)
{ case 1:{
creat(&Q);
Front(Q);
}break;
case 2:{ printf("\n x=?"); scanf("%d",&x);
insert(&Q,x);

声明和定义不一样啊
看声明上是
ElemType Front(SeQueue qq);
可你的实现定义却是
ElemType Delete(SeQueue *Q)

Front函数声明和定义不一样,调用的时候也要改一下。

还有insert的时候是不是先赋值,然后在移动rear。Create这样写不好,不通用,不要把输入输出放到里面,通过数组传过去要好点。

你定义了类型ElemType但是用的时候却当成int来用(Front和Delete在失败的时候返回-1),这样不通用,如果队列中是其他类型如结构体,怎么办,通过参数来返回值,返回一个是否成功的bool值,这样要好一点。

入队和出对的函数名换成更明确一点的会更好点。不好意思,我有点啰嗦^^。