What do you mean by "getting involved with parameters" to use #define instead of using

I was wondering why we use #define with a TMap instead of using.
That is,
#define TMap std::map

instead of,
using TMap = std::map

By “we would have to get involved with parameters”, what do you mean? I read in a discussion (https://stackoverflow.com/questions/36518029/proper-way-to-define-type-typedef-vs-define) that using #define can be a bad idea and we should avoid using pre-processor directives as much as possible.

On that note, why don’t we use a typedef instead of using or #define?
That is,
typedef std::map TMap

Hello @sudhamr.

#define is a preprocessor directive (something that is run before compilation) and it’s a simple text replacement. 4) C-code is more transportable between different machine architectures. The facilities provided by a preprocessor are given below:

  1. File inclusion
  2. Substitution facility
  3. Conditional compilation

Cheers
Kevin

Privacy & Terms