开发者

struct object same name as data name

开发者 https://www.devze.com 2023-03-27 23:13 出处:网络
I have come across code like this : struct abc { //some code }; //some lines of code struct abc *abc; I have a couple of questions:

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

精彩评论

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