CComSafeArrayBound 类
此类是 SAFEARRAYBOUND 结构的包装器。
语法
class CComSafeArrayBound : public SAFEARRAYBOUND
成员
方法
函数 | 说明 |
---|---|
CComSafeArrayBound | 构造函数。 |
GetCount | 调用此方法可返回元素的数目。 |
GetLowerBound | 调用此方法可返回下限。 |
GetUpperBound | 调用此方法可返回上限。 |
SetCount | 调用此方法可设置元素的数目。 |
SetLowerBound | 调用此方法可设置下限。 |
运算符
运算符 | 说明 |
---|---|
operator = | 将 CComSafeArrayBound 设置为新值。 |
备注
此类是 CComSafeArray 所用的 SAFEARRAYBOUND
结构的包装器。 它提供方法来查询和设置 CComSafeArray
对象的单个维度的上限和下限及其包含的元素数目。 多维 CComSafeArray
对象使用 CComSafeArrayBound
对象数组,每个维度使用一个数组。 因此,使用 GetCount 等方法时,请注意,该方法不会返回多维数组中的元素总数。
标头: atlsafe.h
要求
标头: atlsafe.h
CComSafeArrayBound::CComSafeArrayBound
构造函数。
CComSafeArrayBound(ULONG ulCount = 0, LONG lLowerBound = 0) throw();
参数
ulCount
数组中的 元素数。
lLowerBound
数组编号的下限。
注解
如果要从 C++ 程序访问数组,建议将下限定义为 0。 如果要将数组与其他语言(如 Visual Basic)一起使用,则最好使用其他下限值。
CComSafeArrayBound::GetCount
调用此方法可返回元素的数目。
ULONG GetCount() const throw();
返回值
返回元素的数目。
备注
如果关联的 CComSafeArray
对象表示多维数组,此方法将仅返回最右侧维度中的元素的总数目。 使用 CComSafeArray::GetCount 可获取元素的总数目。
CComSafeArrayBound::GetLowerBound
调用此方法可返回下限。
LONG GetLowerBound() const throw();
返回值
返回 CComSafeArrayBound
对象的下限。
CComSafeArrayBound::GetUpperBound
调用此方法可返回上限。
LONG GetUpperBound() const throw();
返回值
返回 CComSafeArrayBound
对象的上限。
备注
上限取决于元素的数目和下限值。 例如,如果下限为 0 且元素数为 10,则上限将自动设置为 9。
CComSafeArrayBound::operator =
将 CComSafeArrayBound
设置为新值。
CComSafeArrayBound& operator= (const CComSafeArrayBound& bound) throw();
CComSafeArrayBound& operator= (ULONG ulCount) throw();
参数
bound
CComSafeArrayBound
对象。
ulCount
元素数量。
返回值
返回指向 CComSafeArrayBound
对象的指针。
备注
可以使用现有 CComSafeArrayBound
或提供元素数来分配 CComSafeArrayBound
对象,在这种情况下,下限默认设置为 0。
CComSafeArrayBound::SetCount
调用此方法可设置元素的数目。
ULONG SetCount(ULONG ulCount) throw();
参数
ulCount
元素数量。
返回值
返回 CComSafeArrayBound
对象中的元素数。
CComSafeArrayBound::SetLowerBound
调用此方法可设置下限。
LONG SetLowerBound(LONG lLowerBound) throw();
参数
lLowerBound
下限。
返回值
返回 CComSafeArrayBound
对象的新下限。
备注
如果要从 Visual C++ 程序访问数组,建议将下限定义为 0。 如果要将数组与其他语言(如 Visual Basic)一起使用,则最好使用其他下限值。
上限取决于元素的数目和下限值。 例如,如果下限为 0 且元素数为 10,则上限将自动设置为 9。