| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1787 人关注过本帖
标题:error C2011: 'node' : 'struct' type redefinition
只看楼主 加入收藏
a740612348
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-20
结帖率:83.33%
收藏
 问题点数:0 回复次数:3 
error C2011: 'node' : 'struct' type redefinition
typedef struct node
{
    char no[7];
    int time;
}Carnode;这样定义有错吗?为什么显示错误?
2012-10-25 20:34
yanggy11
Rank: 1
等 级:新手上路
帖 子:6
专家分:4
注 册:2012-10-25
收藏
得分:0 
没错啊,你是不是在其他地方定义了node结构,
2012-10-25 21:44
a740612348
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-20
收藏
得分:0 
回复 2楼 yanggy11
我是用数据结构的,要不你帮我看下代码?
2012-10-25 22:19
a740612348
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-9-20
收藏
得分:0 
我的代码的头文件和源文件是这样的:停车场管理的:
base.h:
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <math.h>
#include <process.h>
#include <conio.h>
#define OK 1
#define ERROR 0
#define STACKSIZE 100
#define STACKINCREMENT 10
typedef struct node
{
    char no[7];
    int time;
}Carnode;
链队列.h:
#include"base.h"
typedef struct QNode
{
    char no[7];
    int time;
    struct QNode *next;
}QNode,*Queueptr;
typedef struct
{
    Queueptr front;
    Queueptr rear;
}Linkqueue;
int Initqueue(Linkqueue &q);
int DestroyQueue(Linkqueue &q);
int Queuelength(Linkqueue q);
int Enqueue(Linkqueue &q,Carnode e);
int Dequeue(Linkqueue &q,Carnode &e);
顺序栈.h:
#include"base.h"
typedef struct zhan
{
    Carnode *base;
    Carnode *top;
    int stacksize;
}Sqstack;
int Initstack (Sqstack &s);
int Destroystack (Sqstack &s);
int Stacklength (Sqstack s);
int Gettop (Sqstack s,Carnode &e);
int Push(Sqstack &s,Carnode e);
int Pop(Sqstack &s,Carnode &e);
顺序栈.c:
#include "顺序栈.h"
#include"base.h"
int Initstack (Sqstack &s)
{
    s.base=(Carnode *)malloc(STACKSIZE*sizeof(Carnode));
    if (!s.base)
        exit(0);
    s.top=s.base;
    s.stacksize=STACKSIZE;
    return OK;
}
int Destroystack (Sqstack &s)
{
    free (s.base);
    s.top=s.base;
    s.stacksize=0;
    return OK;
}
int Stacklength (Sqstack s)
{
    return s.top-s.base;
}
int Gettop (Sqstack s,Carnode &e)
{
    if (s.top==s.base)
        return ERROR;
    e=*(--s.top);
    return OK;
}
int Push(Sqstack &s,Carnode e)
{
    if (s.top-s.base>=s.stacksize)
    {
        s.base=(Carnode *)realloc(s.base,(s.stacksize+STACKSIZE)*sizeof(Carnode));
        if (!s.base)
            exit (0);
        s.top=s.base+s.stacksize;
        s.stacksize=s.stacksize+STACKSIZE;
    }
    *(s.top++)=e;
    return OK;
}
int Pop(Sqstack &s,Carnode &e)
{
    if (s.top==s.base)
        return ERROR;
    e=*--s.top;
    return OK;
}
链队列.c:
#include"链队列.h"
#include"base.h"
int Initqueue(Linkqueue &q)
{
    q.front=q.rear=(Queueptr)malloc(sizeof(QNode));
    if(!q.front)
        exit(0);
    q.front->next=NULL;
    return OK;
}
int DestroyQueue(Linkqueue &q)
{
    while(q.front)
    {
        q.rear=q.front->next;
        free(q.front);
        q.front=q.rear;
    }
    return OK;
}
int Queuelength(Linkqueue q)
{
    return q.rear-q.front;
}
int Enqueue(Linkqueue &q,Carnode e)
{
    Queueptr p;
    p=(Queueptr)malloc(sizeof(QNode));
    if(!p)
        exit(0);
    p->no=e->no;
    p.time=e.time;
    p->next=NULL;
    q.rear->next=p;
    q.rear=p;
    return OK;
}
int Dequeue(Linkqueue &q,Carnode &e)
{
    Queueptr p;
    if (q.front==q.rear)
        return ERROR;
    p=q.front->next;
    e.no=p->no;
    e.time=p.time;
    q.front->next=p->next;
    if (q.rear==p)
        q.rear=q.front;
    free(p);
    return OK;
}

望众人手帮忙!
2012-10-25 22:30
快速回复:error C2011: 'node' : 'struct' type redefinition
数据加载中...
 
   



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

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