🔒 Locked
Typedef?
Advertisement
Original Post
Basically its like renaming something
a good example IMO is
typedef unsigned short USHORT;
everytime I want to make an unsigned short I could write this:
USHORT shortInt;
instead of:
unsigned short shortInt;
Basically to my knowledge( which isn''t much ) thats what it used for.
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
a good example IMO is
typedef unsigned short USHORT;
everytime I want to make an unsigned short I could write this:
USHORT shortInt;
instead of:
unsigned short shortInt;
Basically to my knowledge( which isn''t much ) thats what it used for.
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Simbiant:
1) Defines are more ''dangerous'' than typedefs.
2) You can do more complex things with typedefs:
I think I prefer the first one. I don''t know about you, but I prefer the safer, more versatile, typedef solution to the macro solution in every situation possible
.
[Resist Windows XP''s Invasive Production Activation Technology!]
1) Defines are more ''dangerous'' than typedefs.
2) You can do more complex things with typedefs:
|
I think I prefer the first one. I don''t know about you, but I prefer the safer, more versatile, typedef solution to the macro solution in every situation possible
[Resist Windows XP''s Invasive Production Activation Technology!]
quote:
Original post by doogle
Why do you make it a typedef, not just a struct?
Older versions of C wouldn''t allow you to declare an instance of that structure without the use of the struct keyword unless you had typedef (making the tag an alias for the struct).
It''s deprecated, so don''t worry about it.
quote:
Original post by zipless
I''m pretty sure that typedef''s aren''t part of C++ and as a result all structs are automatically typedefs (or something like that).
The typedef keyword is part of C++, it just is no longer required for struct''s. See Oluseyi''s post.
[Resist Windows XP''s Invasive Production Activation Technology!]
quote:
Original post by zipless
I''m pretty sure that typedef''s aren''t part of C++...
Wrong. All structs are typedef in a sense, since structs are classes with default public visibility, but typedefs do still exist and are useful. take a look at all the non-struct related examples in this thread alone.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement