Share via


CObArray::GetSize

Returns the size of the array.

INT_PTR GetSize( ) const;

Remarks

Since 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::GetSize.

Class

Member Function

CByteArray

INT_PTR GetSize( ) const;

CDWordArray

INT_PTR GetSize( ) const;

CPtrArray

INT_PTR GetSize( ) const;

CStringArray

INT_PTR GetSize( ) const;

CUIntArray

INT_PTR GetSize( ) const;

CWordArray

INT_PTR GetSize( ) 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.GetSize(); i++)
{
   CAge*& pAge = (CAge*&) myArray.ElementAt(i);
   delete pAge;
   pAge = new CAge(100+i);
}

#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << _T("myArray: ") << &myArray << _T("\n");
#endif      

Requirements

Header: afxcoll.h

See Also

Reference

CObArray Class

Hierarchy Chart

CObArray::GetUpperBound

CObArray::SetSize

CObArray::GetCount