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:
- Is there an advantage to this usage?
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
.
精彩评论