Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mage2k

typedef

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Anybody: Is there any difference between:
struct StructTypeName{
   ...
};
 
or,
typedef struct{
   ...
} StructTypeName;
 
Doesn''t the first do implicitly what the second does explicitly? peace and (trance) out Mage

Share this post


Link to post
Share on other sites
Advertisement
In C, the second one allows you to refer to the type without using "struct". In C++, they are identical.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
Well, they''re slightly different in C++.

The first reason is that typedef form cannot declare a constructor.

The second reason is that it becomes illegal in the second form to reference the type like:
struct StructTypeName * ptr;

Share this post


Link to post
Share on other sites
Ok, so with C++ no problem because having to put struct before the typename in variable declarations is annoying anywayz.

peace and (trance) out

Mage

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!