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, 1025👍, 0💬
Popular Posts:
How To Avoid the Undefined Index Error? - PHP Script Tips - Processing Web Forms If you don't want y...
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?...
.NET INTERVIEW QUESTIONS - Can we use events with threading ? Yes, you can use events with thread; t...
How Do I Run JUnit Tests from Command Window? To run JUnit tests from a command window, you need to ...
What Is a LABEL Tag/Element? - XHTML 1.0 Tutorials - Understanding Forms and Input Fields A "label" ...