以下哪个示例是声明以下函数的更好方法,为什么?
void myFunction (const int &myArgument);
或
void myFunction (int myArgument);
最佳答案
使用 const T & arg
如果 sizeof(T)>sizeof(void*)
并使用 T arg
如果 sizeof(T) <= sizeof(void*)
关于c++ - "const T &arg"与 "T arg",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1567138/