CArray使用一点

来源:互联网 发布:linux vi编写程序 编辑:程序博客网 时间:2024/05/16 04:56
template < class TYPE, class ARG_TYPE = const TYPE& >class CArray :   public CObject
TYPE
Template parameter specifying the type of objects stored in the array. TYPE is a parameter that is returned by CArray.
ARG_TYPE
Template parameter specifying the argument type used to access objects stored in the array. Often a reference to TYPE. ARG_TYPE is a parameter that is passed to CArray.

我的使用例子:

CArray<int, int&> arr;

则下面使用出现错误

arr.setAt(0, 0);

第二个值需为引用,常量是通不过编译。

 

这说明对CArray数组的元素,存取都是按照int&类型来进行的。

 

原创粉丝点击