Share via


CObArray::Add

Agrega un nuevo elemento al final de una matriz, aumentando la matriz en 1.

INT_PTR Add(
   CObject* newElement 
);

Parámetros

  • newElement
    El puntero de CObject se agregue a esta matriz.

Valor devuelto

El índice del elemento agregado.

Comentarios

Si SetSize utilizada con un valor de nGrowBy mayor que 1, entonces la adicional puede ser asignada.Sin embargo, el límite superior aumentará sólo durante 1.

La tabla siguiente se muestran otras funciones miembro que son similares a CObArray::Add.

Clase

Función miembro

CByteArray

INT_PTR agregan (BYTE newElement);

    throw (CMemoryException*);

CDWordArray

INT_PTR agregan (DWORD newElement);

    throw (CMemoryException*);

CPtrArray

INT_PTR agregan (void* newElement);

    throw (CMemoryException*);

CStringArray

INT_PTR agregan (LPCTSTR newElement);throw (CMemoryException*);

INT_PTR agregan (const CString&newElement);

CUIntArray

INT_PTR agregan (UINT newElement);

    throw (CMemoryException*);

CWordArray

INT_PTR agregan (WORD newElement);

    throw (CMemoryException*);

Ejemplo

Vea CObList:: CObList para una lista de la clase de CAge utilizada en todos los ejemplos de la colección.

CObArray arr;

arr.Add(new CAge(21)); // Element 0
arr.Add(new CAge(40)); // Element 1
#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << _T("Add example: ") << &arr << _T("\n");
#endif      

Los resultados de este programa son los siguientes:

Add example: A CObArray with 2 elements

[0] = a CAge at $442A 21

[1] = a CAge at $4468 40

Requisitos

encabezado: afxcoll.h

Vea también

Referencia

Clase de CObArray

Gráfico de jerarquía

CObArray::SetAt

CObArray::SetAtGrow

CObArray::InsertAt

CObArray::operator [ ]