Re: why use typedef instead of define?
From: Lisa Pearlson (no_at_spam.plz)
Date: 10/18/04
- Next message: hahasnoopy: "Re: how to show custom file in IE?thank you."
- Previous message: Lisa Pearlson: "Re: how to show custom file in IE?thank you."
- In reply to: Doug Harrison [MVP]: "Re: why use typedef instead of define?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 18 Oct 2004 05:24:07 +0200
Cool, never thought about this before.
So typedef is definitely the recommended way.
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:8sc6n01pqc77mpqjo7mic17rs5a3fbrie0@4ax.com...
> 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: hahasnoopy: "Re: how to show custom file in IE?thank you."
- Previous message: Lisa Pearlson: "Re: how to show custom file in IE?thank you."
- In reply to: Doug Harrison [MVP]: "Re: why use typedef instead of define?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|