C语言的联合体应用出错,该怎么处理
C语言的联合体应用出错
#define MAX_FEATURE_NUM 42
#define MAXNumber 70
#define MAXLINE 500
#define NUMBER 494021
#define ERROR -1
#define NULL -1
typedef struct ArcBox
{
int tail,head;
struct ArcBox * hlink,* tlink;
}ArcBox;
typedef struct FeaNode
{
char * feaname;
int type;
union range
{
char * c_range[MAXNumber];
int i_range[MAXNumber];
double d_range[MAXNumber];
};
int indegree;
int valuenum;
int visit[MAXNumber];
struct ArcBox * parent,* child;
}FeaNode;
typedef struct
{
struct FeaNode fealist[MAX_FEATURE_NUM];
int feanum,arcnum;
}BayesNetwork;
struct LNode
{
int sequence;
int valuenum;
int n;
int flag;
int type;
union Lrange
{
char ** c_range;
int * i_range;
double * d_range;
};
int * visit;
struct LNode * next;
};
typedef struct LNode * Linklist;
Linklist CalParent (BayesNetwork * nb,int i)
{
struct ArcBox * r;
struct LNode * p,* q;
Linklist head=(Linklist)malloc(sizeof(struct LNode));
if(!head)
{
error ( "No space for node can be obtained! ");
return ERROR;
}
p=head;
r=(* nb).fealist[i].parent;
while(r)
{
q=(struct LNode *)malloc(sizeof(struct LNode));
if(!q)
{
error( "No space for node can be obtained! ");
return ERROR;
}
q-> type=(* nb).fealist[r-> tail].type;
q-> Lrange.d_range=(* nb).fealist[r-> tail].range.d_range;
q-> visit=(* nb).fealist[r-> tail].visit;
q-> sequence=r-> tail;
q-> valuenum=(* nb).fealist[r-> tail].valuenum;
q-> n=0;
clear(q-> visit,q-> valuenum);
p-> next=q;
p=q;
r-> hlink=r;
}
p-> next=NULL;
return(head);
}
错误提示为:
D:\My Documents\3\Enum.C(38) : error C2039: 'Lrange ' : is not a member of 'LNode '
d:\my documents\3\linklist.h(2) : see declaration of 'LNode '
D:\My Documents\3\Enum.C(38) : error C2039: 'range ' : is not a member of 'FeaNode '
d:\my documents\3\bayesnetwork.h(14) : see declaration of 'FeaNode '
#define MAX_FEATURE_NUM 42
#define MAXNumber 70
#define MAXLINE 500
#define NUMBER 494021
#define ERROR -1
#define NULL -1
typedef struct ArcBox
{
int tail,head;
struct ArcBox * hlink,* tlink;
}ArcBox;
typedef struct FeaNode
{
char * feaname;
int type;
union range
{
char * c_range[MAXNumber];
int i_range[MAXNumber];
double d_range[MAXNumber];
};
int indegree;
int valuenum;
int visit[MAXNumber];
struct ArcBox * parent,* child;
}FeaNode;
typedef struct
{
struct FeaNode fealist[MAX_FEATURE_NUM];
int feanum,arcnum;
}BayesNetwork;
struct LNode
{
int sequence;
int valuenum;
int n;
int flag;
int type;
union Lrange
{
char ** c_range;
int * i_range;
double * d_range;
};
int * visit;
struct LNode * next;
};
typedef struct LNode * Linklist;
Linklist CalParent (BayesNetwork * nb,int i)
{
struct ArcBox * r;
struct LNode * p,* q;
Linklist head=(Linklist)malloc(sizeof(struct LNode));
if(!head)
{
error ( "No space for node can be obtained! ");
return ERROR;
}
p=head;
r=(* nb).fealist[i].parent;
while(r)
{
q=(struct LNode *)malloc(sizeof(struct LNode));
if(!q)
{
error( "No space for node can be obtained! ");
return ERROR;
}
q-> type=(* nb).fealist[r-> tail].type;
q-> Lrange.d_range=(* nb).fealist[r-> tail].range.d_range;
q-> visit=(* nb).fealist[r-> tail].visit;
q-> sequence=r-> tail;
q-> valuenum=(* nb).fealist[r-> tail].valuenum;
q-> n=0;
clear(q-> visit,q-> valuenum);
p-> next=q;
p=q;
r-> hlink=r;
}
p-> next=NULL;
return(head);
}
错误提示为:
D:\My Documents\3\Enum.C(38) : error C2039: 'Lrange ' : is not a member of 'LNode '
d:\my documents\3\linklist.h(2) : see declaration of 'LNode '
D:\My Documents\3\Enum.C(38) : error C2039: 'range ' : is not a member of 'FeaNode '
d:\my documents\3\bayesnetwork.h(14) : see declaration of 'FeaNode '