What's the difference between this:
andCode:struct aStruct { int aNumber; };
All I can think of is maybe the compiler will replace aStruct with the actual struct{} definition with typedef?Code:typedef struct { int aNumber; } aStruct;
What's the difference between this:
andCode:struct aStruct { int aNumber; };
All I can think of is maybe the compiler will replace aStruct with the actual struct{} definition with typedef?Code:typedef struct { int aNumber; } aStruct;
Using Dev-C++ on Windows
this might explain what you are wondering
http://msdn.microsoft.com/library/de...m/tions_14.asp
I think that the typedef is common in C so you dont have to type struct each time you declared an object (or use one) of that structure. But essentially they are the same thing.
so you dont have to do:
Instead you can do...Code:struct Foo { int a, b; }; int main () { struct Foo testData; }
It's usefull in C because you must specify a struct with "struct" even when declaring or passing the struct, so the client doesn't need to know that Foo is a structure.Code:typedef struct { int a, b; } Foo; int main () { Foo testData; }
Last edited by JoshR; 07-20-2005 at 11:06 PM.
So really it has no difference in C++, just C?
Using Dev-C++ on Windows
Correct. They are the same thing, its just in C you have to use the word "struct" before all variables of a structure. A typedef is a way to get around that.Originally Posted by Ganoosh
I see
Using Dev-C++ on Windows