Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What's the difference between using a typedef or a define for a user-defined type?
What's the difference between using a typedef or a define for a user-defined type?
✍: Guest
In general, typedefs are preferred, in part because they can correctly encode pointer types. For example, consider these declarations:
typedef char *String_t;
#define String_d char *
String_t s1, s2;
String_d s3, s4;
s1, s2, and s3 are all declared as char *, but s4 is declared as a char, which is probably not the intention.
#defines do have the advantage that #ifdef works on them On the other hand, typedefs have the advantage that they obey scope rules (that is, they can be declared local to a function or block).
2016-02-22, 1211👍, 0💬
Popular Posts:
Can you explain duplex contracts in WCF? In duplex contracts when client initiates an operation the ...
If locking is not implemented what issues can occur? IFollowing are the problems that occur if you d...
What are the different elements in Functions points? The different elements in function points are a...
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
How do I use forms? The basic syntax for a form is: <FORM ACTION="[URL]">...&l t;/FORM>Wh...