What is the difference between 'typedef' and 'using' in C++11?

后端 未结 7 811
误落风尘
误落风尘 2020-11-22 03:32

I know that in C++11 we can now use using to write type alias, like typedefs:

typedef int MyInt;

Is, from what I

相关标签:
7条回答
  • 2020-11-22 04:20

    Both keywords are equivalent, but there are a few caveats. One is that declaring a function pointer with using T = int (*)(int, int); is clearer than with typedef int (*T)(int, int);. Second is that template alias form is not possible with typedef. Third is that exposing C API would require typedef in public headers.

    0 讨论(0)
提交回复
热议问题