为什么使用这种结构格式? [英] why use this struct format?

查看:94
本文介绍了为什么使用这种结构格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中一直看到这个:

typedef struct a_struct

{

...

} differentName,* differentNamePtr;

我明白如何使用它,但有人可以告诉我为什么以上是

优于:


struct differentName

{

...

};


It似乎如果你正在创建结构并立即给它一个替代名称

(并且从不使用它的原始名称),那么为什么不给它

替代名称?

我也不知道你在节省什么是通过声明不同的名称为

而不是仅使用differentName *。不同名称*实际上似乎更多

在阅读代码时我很清楚。

尽可能残酷地抓住这一点,我已经做好了准备。 />
谢谢,


-Kilana

I see this all the time in code:
typedef struct a_struct
{
...
}differentName, *differentNamePtr;
I understand how I can use it, but could someone tell me why the above is
superior to:

struct differentName
{
...
};

It seems that if you''re creating the struct and giving it an alternate name
immediately (and never using it''s original name), then why not just give it
the alternate name?
I also don''t understand what you''re saving by declaring differentNamePtr as
opposed to just using differentName *. differentName * actually seems more
clear to me when reading code.
Be as brutal as need be to get the point across, I''m ready for it.
Thanks,

-Kilana

推荐答案

Kilana写道:
Kilana wrote:

似乎如果你正在创建结构并立即给它一个替代名称(并且从不使用它的原始名称),那么为什么不呢?给它
替代名称?

It seems that if you''re creating the struct and giving it an alternate name
immediately (and never using it''s original name), then why not just give it
the alternate name?




这是C的保留,当你的第二个例子中的语法不是

允许。


-

Mike Smith



It''s a holdover from C, when the syntax in your second example was not
permitted.

--
Mike Smith


Mike Smith< mi*******************@acm.DOT.org>写在

news:vm ************ @ news.supernews.com:
Mike Smith <mi*******************@acm.DOT.org> wrote in
news:vm************@news.supernews.com:
Kilana写道:

似乎如果您正在创建结构并立即给它一个替代名称(并且从不使用它的原始名称),那么为什么不呢?只是给它一个替代名称?

It seems that if you''re creating the struct and giving it an
alternate name immediately (and never using it''s original name), then
why not just give it the alternate name?



这是C的保留,当你的第二个例子中的语法不被允许时。

-
Mike Smith



It''s a holdover from C, when the syntax in your second example was not
permitted.

--
Mike Smith




哦,


谢谢:),我一直在想这个多年来,但从未问过。

-K



Ohhhh,

Thanks :), I''ve been wondering about that for years, but never asked.
-K




" Kilana" < KP @ ...>在消息新闻中写道:nh ****************** @ fe03.atl2.webusenet.com。 ..

"Kilana" <kp@...> wrote in message news:nh******************@fe03.atl2.webusenet.com. ..
我在代码中一直看到这个:

typedef struct a_struct
{
I see this all the time in code:
typedef struct a_struct
{



从C.


Carry over from C.


这篇关于为什么使用这种结构格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆