int Add ( CObject * newElement );
gettare ( CMemoryException );
Valore restituito
L'indice dell'elemento aggiunto.
Parametri
newElement
Il puntatore CObject da aggiungere a questa matrice.
Osservazioni
Aggiunge un nuovo elemento alla fine di una matrice, la matrice in crescita del 1. Se SetSize č stato utilizzato con un valore di nGrowBy maggiore di 1, possa essere assegnato memoria aggiuntiva. Tuttavia, il limite superiore aumenterā di solo 1.
La tabella seguente mostra altre funzioni membro che sono simili a CObArray::Add.
| Classe | Funzione membro |
| CByteArray | i&nt Add (BYTE newElement); nbsp; gettare ( CMemoryException ); |
| CDWordArray | i&nt Add (DWORD newElement ); nbsp;gettare ( CMemoryException ); |
| CPtrArray | i&nt Add (void * newElement ); nbsp;gettare ( CMemoryException ); |
| CStringArray | i&nt Add (LPCTSTR newElement ); nbsp;gettare ( CMemoryException ); |
| CUIntArray | int Add (UI&NT newElement ); nbsp;gettare ( CMemoryException ); |
| CWordArray | i&nt Add (parola newElement ); nbsp;gettare ( CMemoryException ); |
Esempio
Vedere CObList::CObList per un elenco della CAge classe utilizzata in tutti gli esempi di raccolta.
/ / esempio per CObArray::Add
nbsp; Matrice di CObArray;
matrice.Aggiungi (nuova gabbia (21)); / / Elemento 0
matrice.Aggiungi (nuova gabbia (40)); / / Elemento 1
ifdef debug
afxDump.SetDepth (1);
afxDump << "Add esempio:" << & matrice << "\n";
# endif
I risultati di questo programma sono i seguenti:
Esempio Add: u&n CObArray con 2 elementi
nbsp; [0] = una gabbia di 442A $ 21
[1] = una gabbia di 4468 $ 40
Pa&noramica CObArray |nbsp; Membri della classe | Gerarchia Chart
Vedere a&nchenbsp;CObArray::SetAt, CObArray::SetAtGrow, CObArray::InsertAt, CObArray::operator]