开发者

struct object same name as data name

I have come across code like this :

struct abc
{
    //some code
};

//some lines of code

struct abc *abc;

I have a couple of questions:

  1. Is there an advantage to this usage?
  2. Does the compiler interpret it d开发者_如何学编程ifferently from:

    struct abc *diffname;
    


There is nothing special about giving a variable a name similar to its type name. For native types, it's impossible, since the type names are all reserved. For your case of structures, however,

struct abc *abc;

and

struct abc *diffname;

are exactly the same, except that they have different names. I don't see any particular "advantage" to using the abc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜