Udostępnij za pośrednictwem


CObArray::GetCount

Returns the number of array elements.

INT_PTR GetCount( ) const;

Return Value

The number of items in the array.

Remarks

Call this method to retrieve the number of elements in the array. Because indexes are zero-based, the size is 1 greater than the largest index.

The following table shows other member functions that are similar to CObArray::GetCount.

Class

Member Function

CByteArray

INT_PTR GetCount( ) const;

CDWordArray

INT_PTR GetCount( ) const;

CPtrArray

INT_PTR GetCount( ) const;

CStringArray

INT_PTR GetCount( ) const;

CUIntArray

INT_PTR GetCount( ) const;

CWordArray

INT_PTR GetCount( ) const;

Example

See CObList::CObList for a listing of the CAge class used in all collection examples.

CObArray myArray;

// Add elements to the array. 
for (int i = 0; i < 10; i+)
   myArray.Add(new CAge(i));

// Add 100 to all the elements of the array. 
for (int i = 0; i < myArray.GetCount(); i+)
{
   CAge*& pAge = (CAge*&) myArray.ElementAt(i);
   delete pAge;
   pAge = new CAge(100 + i);
}

Requirements

Header: afxcoll.h

See Also

Reference

CObArray Class

Hierarchy Chart

CObArray::GetUpperBound

CObArray::SetSize

CObArray::GetSize

Other Resources

CObArray Members