标题:typedef struct 的问题
取消只看楼主
wuzangtian
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-6-17
结帖率:100%
 问题点数:0 回复次数:3 
typedef struct 的问题
程序代码:
typedef struct a_stm_ *a_stm;
typedef struct a_explist *a_explist;
struct a_stm_ 
{
emu{a,b,c}kind;
union
{
  struct{a_stm stm1,stm2}compound;  

 struct{a_explist exps}print;
}u;
};
a_stm a_compoundstm(a_stm stm1,a_stm stm2);

a_stm a_compoundstm(a_stm stm1,a_stm stm2);这句看不懂,求解释
搜索更多相关主题的帖子: compound 
2012-06-30 23:15
wuzangtian
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-6-17
得分:0 
继续看书,看懂了==。。,原来a_compoundstm(a_stm stm1,a_stm stm2)是一个构造函数名
2012-06-30 23:26
wuzangtian
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-6-17
得分:0 
回复 4楼 fenghelong
这是现代编译原理里面的一段代码,用C语言编写编译器,表示目前还是一知半解==。。
2012-07-02 17:44
wuzangtian
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2012-6-17
得分:0 
回复 6楼 nzxiansheng
书上写:constructor fun 定义是这样的:
程序代码:
a_stm a_compoundstm(a_stm stm1,a_stm stm2)
{
    a_stm s=checked_malloc(sizeof(*s));
    s->kind=a_compoundstm;
    s-> s-> return s;
}
创建一个构造器,用malloc为此数据结构分配空间并初始化

2012-07-02 20:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-372566-1-1.html




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

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