c++ - #define file type -


is

#define lbitmap std::list < cbitmap *> 

a practice?

edit: allright, can convince boss bad practice?

no, not practice use #define in c++.

its use typedef has defined scope

typedef scope defined , compiler interprets definition each time meet not in case of #define. #define interpreted compile time itself.

here msdn definition of typedef , #define

a typedef declaration introduces name that, within scope, becomes synonym type given type-declaration portion of declaration

when using define statements, instances of statement replaced value of statement during preprocessing phase.

#define lbitmap std::list < cbitmap *>   // bad  typedef std::list < cbitmap *> lbitmap  // 

to convince boss

#define charptr char* 

charptr a, b;

after preprocessing, line expands to

char* a, b; 

here, variable of type char * whereas b char

if use typedef

typedef char* charptr; charptr a, b; 

here both , b both of type char *


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -