如果CArray的ARG_TYPE是const&或不 [英] Should the ARG_TYPE for a CArray be const & or not
本文介绍了如果CArray的ARG_TYPE是const&或不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这两行之间有什么区别
CArray<MyClass, MyClass> MyArray
CArray<MyClass, const MyClass & > MyArray
推荐答案
MyClass总是复制到数组。但是第一个表单复制它两次:第一次当它作为参数提供给Add或SetAt函数,第二次在内部。
使用第二个表单避免第一个副本。
The MyClass is always copied to the array. But the first form copies it twice: the first time when its given as a parameter to the Add or SetAt function, the second time internally. With the second form you avoid the first copy.
这篇关于如果CArray的ARG_TYPE是const&或不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文