Skip to main content
GameDev.net gamedev.net
๐Ÿ”’ Locked

typedef

Started by NUCLEAR RABBIT Aug 30, 2006 at 9:05 PM 2 replies 350+ views
Original Post
NUCLEAR RABBIT
NUCLEAR RABBIT
Hello, Can someone please tell me what the difference is between the following 2 examples:

ex1:

typedef struct // what does the typedef do for the struct?
{
    int x;
    int y;
} placeName;

ex2:

struct placeName
{
    int x;
    int y;
};


Thanks for any help.
Mushu
Mushu
typedef struct is a reminant of C. Assuming you're using C++, they're syntatically equivalent.
blaze02
blaze02
In C, you can NOT simply say
placeName variable;
using the 2nd example. C requires
struct placeName variable;
Now if you use the typedef version (ex1), you can say
placeName variable;
and expect it to compile in C.

Using C++, the examples are virtually the same.
NUCLEAR RABBIT
NUCLEAR RABBIT
Thank you guys for the very fast and helpful replies [smile]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.