1

In C++, what is the preferred way to define type alias?

#define intAliasType int
typedef int intAliasType
using intAliasType = int;

I heard that you shouldn't use #define, and typedef is discouraged in C++, so I should use using. But is that true?

  • 2
    #define is a bad practice in C++ and C. It makes debugging difficult: you see different types in a debugger and a source code. As for `using` or `typedef`, this question is answered https://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11. – 273K Dec 25 '21 at 03:45
  • Yes use : using. – Pepijn Kramer Dec 25 '21 at 06:53

0 Answers0