在堆栈ADT中声明各种typedef

时间:2013-04-30 16:13:54

标签: c struct abstract-data-type

这是我的问题:我需要实现一个FIFO / LIFO列表堆栈作为ADT种类1.我的程序是模块化的,它有一个item.h模块:

    #ifndef ITEM_H_INCLUDED
    #define ITEM_H_INCLUDED

    typedef struct
    {
        char stringa[20];
        int numero;
    } Item;        
    #endif // ITEM_H_INCLUDED

head.h模块:

#ifndef HEAD_H_INCLUDED
#define HEAD_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>

#include "item.h"  

void QUEUEinit();
int QUEUEempty();
void QUEUEput_top(Item);
void QUEUEput_bottom(Item);
Item QUEUEget_top();
Item QUEUEget_bottom();

#endif // HEAD_H_INCLUDED

main.c和data.c;我需要的是如何声明QEUEnode struct以及在哪里。

感谢您的帮助:)

1 个答案:

答案 0 :(得分:1)

由于您的QUEUE *函数都没有收到QUEUEnode *,因此您可以将它隐藏在head.c文件中,以及它们运行的​​QUEUEnode root;

如果你想使用多个队列,那么它应该在head.h文件中,这样它们就可以在main.c中创建。为此,您还需要修改函数以接受要操作的队列。