在C++中,多次声明变量会在编译期间显示错误.例如:
int x; int x;
在多次声明函数时,编译期间不会显示任何错误.例如:
int add(int, int); int add(int, int);
为什么在C++中有这种区别?
c++ declaration definition one-definition-rule
c++ ×1
declaration ×1
definition ×1
one-definition-rule ×1