本文介绍了“const T& arg”与“T arg”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你有一个函数,例如 int ,什么是更好的方式声明函数,为什么是一个比另一个更好?

If you have a function which takes for example an int, what is the better way of declaring the function and why is one better than the other one?

void myFunction (const int &myArgument);

void myFunction (int myArgument);


推荐答案

使用 const T& arg 如果 sizeof(T)> sizeof(void *) if sizeof(T)< = sizeof(void *)

这篇关于“const T&amp; arg”与“T arg”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 08:13
查看更多