Cleared my basics from this site:
#define is a macro in C++ used as:
#define MACRO_NAME VALUE
For example, `#define SIZE 100`,
Macro makes the replacements at the time of preprocessing, before compilation. All the values are put in expanded code before usual compilation starts.
typedef gives another name to a type and it is used as:
typedef TYPE NEW_TYPE;
Unlike #define it is interpreted by compiler and works as a new name for `TYPE`
See they are looking similiar, if I write
#define TYPE int or
typedef int INT what’s the difference here.
#define CHAR_PTR char* and
typedef char* CHAR_PTR, lets take them one by one:
#define CHAR_PTR char* ... CHAR_PTR a, b; //typeid(a).name = char* and typeid(b).name = char //because it is simply a replacement _________________________________________________________________ typedef char* CHAR_PTR; ... CHAR_PTR a,c; //typeid(a).name() = typeid(b).name = char*
Sources: StackOverflow, Let Us C, The C Programming Language -K&R