Re: why use typedef instead of define?
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 10/18/04
- Next message: Lisa Pearlson: "Most efficient and accurate mathematics?"
- Previous message: Doug Harrison [MVP]: "Re: why use typedef instead of define?"
- In reply to: Lisa Pearlson: "why use typedef instead of define?"
- Next in thread: Lisa Pearlson: "Re: why use typedef instead of define?"
- Reply: Lisa Pearlson: "Re: why use typedef instead of define?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 17 Oct 2004 22:17:33 -0500
Lisa Pearlson wrote:
>Hi:
>
>what's the difference between:
>
>typedef sometype mytype;
>
>and
>
>#define mytpe sometype
Macros use textual substitution, while typedefs do not. Here are a couple of
cases where it matters:
#define INTP_MACRO int*
typedef int* INTP_TYPEDEF;
INTP_MACRO x, y; // x is int*, y is just int
INTP_TYPEDEF x, y; // Both are int*
const INTP_MACRO p1; // p1 is const int*
INTP_MACRO const p2; // p2 is int* const
const INTP_TYPEDEF p3; // p3 is int* const
INTP_TYPEDEF const p4; // p4 is int* const
-- Doug Harrison Microsoft MVP - Visual C++
- Next message: Lisa Pearlson: "Most efficient and accurate mathematics?"
- Previous message: Doug Harrison [MVP]: "Re: why use typedef instead of define?"
- In reply to: Lisa Pearlson: "why use typedef instead of define?"
- Next in thread: Lisa Pearlson: "Re: why use typedef instead of define?"
- Reply: Lisa Pearlson: "Re: why use typedef instead of define?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|