P
parag_paul
Is there any particular point that makes typedef different than
#define
#define
Is there any particular point that makes typedef different than
#define
For example,
if you use #define to define a new type, like this:
#define foo_t unsigned int *
then,
foo_t a, b;
'a' has type of 'unsigned int *', while 'b' has type of
'unsigned int'.
If you use typedef, you will get the correct behavior.
typedef unsigned int * foo_t;
foo_t a, b;
Both 'a' and 'b' have a pointer type.
using namespace std;#include <iostream>
thanks Wang
Is there any particular point that makes typedef different than
#define
WANG said:For example,
if you use #define to define a new type, like this:
#define foo_t unsigned int *
then,
foo_t a, b;
'a' has type of 'unsigned int *', while 'b' has type of
'unsigned int'.
Juha said:There are also some types which are basically impossible to implement
as a #define. For instance:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.