对于定义一般类型的别名,二者没有区别。 对于定义模板的别名,只能用using。(c++11 还是鼓励用using) 12345678910111213141516171819202122#include <iostream>template <typename T>class A{public: A() { std::cout << "A " << typeid(T).name() << std::endl; }};template <typename T>using B = A<T>;template <typename T>typedef A<T> C;int main(){ A<int> a; B<int> b; // OK, B is an alias of class A. C<int> c; // Syntax Error, C cannot be recognized as a type. return 0;}Author: Bert ZhangLink: https://bert-z.github.io/2020/05/29/typedef-vs-using/Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.CppPrevious Post[转载]cpp 宏操作Next Post[转载]C++中虚函数、虚继承内存模型 Recommend 2020-05-15[转载]在 C++ 中分割字符串 2020-05-15[转载]在 C++ 中读取字符串中成对定界符中的子串 2020-05-19New Work(开个新坑) 2020-05-28[转载]C++中虚函数、虚继承内存模型 2020-05-30[转载]cpp 宏操作 2020-05-30[转载]【C++基础之十】友元函数和友元类