Tag: 强类型

为什么typedef不是强类型的?

typedefs没有强类型的原因是什么? 有什么好处我看不到,还是因为向后兼容? 看这个例子: typedef int Velocity; void foo(Velocity v) { //do anything; } int main() { int i=4; foo(i); //Should result in compile error if strongly typed. return 0; } 我不是要求变通方法来获得强类型数据类型,而只是想知道为什么标准不要求强类型的typedefs ? 谢谢。