| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1852 人关注过本帖
标题:关于头文件的包含的问题
只看楼主 加入收藏
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
结帖率:95.74%
收藏
已结贴  问题点数:20 回复次数:25 
关于头文件的包含的问题
一个头文件poly.h内容
程序代码:
#ifndef PLOY_H
#define PLOY_H
#include "list_seq.h"

typedef struct tagpoly
    {
    int exp;//指数
    float coef;//系数
    }Poly,PPoly;

typedef struct taghead
    {
    int max_exp;
    int n;//真正有用的数的个数
    plist_seq head;
    }PolyHead,*PPolyHead;
另外一个头文件内容list_seq.h
程序代码:
typedef struct tagpoly DATETYPE;
typedef int (*compare)(DATETYPE r_date,DATETYPE d_date);
typedef struct tag_list_seq
{
    int max_num;
    int num;
    DATETYPE *element;
}list_seq,*plist_seq;

编译的时候出现
--------------------Configuration: polystudy - Win32 Debug--------------------
Compiling...
list_seq.cpp
c:\documents and settings\administrator\桌面\polystudy\poly.h(15) : error C2146: syntax error : missing ';' before identifier 'head'
这里说明plist_seq没有申明到啊。。。。。

c:\documents and settings\administrator\桌面\polystudy\poly.h(15) : error C2501: 'plist_seq' : missing storage-class or type specifiers
c:\documents and settings\administrator\桌面\polystudy\poly.h(15) : error C2501: 'head' : missing storage-class or type specifiers
Error executing cl.exe.
polystudy.exe - 3 error(s), 0 warning(s)
貌似是头文件的链接出现问题。。。。。
这2个头文件互相包含要怎么处理啊
搜索更多相关主题的帖子: 内容 
2011-09-30 10:57
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
第一个最后少个#endif

我们都在路上。。。。。
2011-09-30 11:12
zjk103
Rank: 2
等 级:论坛游民
帖 子:22
专家分:60
注 册:2011-5-13
收藏
得分:0 
额,这个不太懂的说。。。
2011-09-30 11:18
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:0 
回复 2楼 hellovfp
貌似不是的
我只贴了一部分。。。
list_seq.h
程序代码:
#ifndef  LIST_SEQ_H
#define  LIST_SEQ_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "poly.h"

typedef struct tagpoly DATETYPE;
typedef int (*compare)(DATETYPE r_date,DATETYPE d_date);
typedef struct tag_list_seq
{
    int max_num;
    int num;
    DATETYPE *element;
}list_seq,*plist_seq;


int list_seq_create(int max,plist_seq *head);
void list_seq_destroy(plist_seq head);
int list_seq_add(DATETYPE *date,plist_seq head);
int list_seq_insert(int location,DATETYPE *date,plist_seq head);
int list_seq_delet(int loction,plist_seq head);
int list_seq_location(DATETYPE *element,compare fun_compare,plist_seq head);
//void list_seq_sort();
void list_seq_sort(compare fun_compare,plist_seq head);
void list_seq_show(plist_seq head);
#endif
第二个poly.h
程序代码:
#ifndef PLOY_H
#define PLOY_H
#include "list_seq.h"

typedef struct tagpoly
    {
    int exp;//指数
    float coef;//系数
    }Poly,PPoly;

typedef struct taghead
    {
    int max_exp;
    int n;//真正有用的数的个数
    plist_seq head;
    }PolyHead,*PPolyHead;

int InitPoly(int max_exp,int n);
void Polyinfo(int n);
void PolyShow(PPolyHead head);
PPoly PolyAdd(PPoly head1,PPoly head2);
PPoly PolySub(PPoly head1,PPoly head2);
PPoly PolyMulti(PPoly head1,PPoly head2);
#endif


 

用心做一件事情就这么简单
2011-09-30 11:26
A13433758072
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:广东潮州
等 级:小飞侠
威 望:1
帖 子:1182
专家分:2784
注 册:2010-7-22
收藏
得分:0 
回复 楼主 小鱼儿c
plist_seq head;你想定义    head的类型?可你用错了

一步一个脚印...............................默默地前进.....
诚邀乐于解答c菜鸟问题,的热心网友加入,  QQ群38490319
2011-09-30 11:28
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:0 
回复 5楼 A13433758072
怎么定义错了呢 。。
明示一下

用心做一件事情就这么简单
2011-09-30 11:31
小鱼儿c
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:852
专家分:1317
注 册:2011-4-1
收藏
得分:0 
他明明显示是没有问题。。
用的时候就不行了。。郁闷啊

用心做一件事情就这么简单
2011-09-30 11:33
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
我的可以通过编译。。
test.rar (2.56 KB)

我们都在路上。。。。。
2011-09-30 11:41
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
国庆前一天还在猛写代码,呵呵,爽呀。。。
提前祝大家国庆快乐啦,哈哈。

我们都在路上。。。。。
2011-09-30 11:48
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
相互包含头文件在编译器看来,其实只要用#ifndef...#endif对,你的头文件实际只处理了一次。

我们都在路上。。。。。
2011-09-30 11:50
快速回复:关于头文件的包含的问题
数据加载中...
 
   



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

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