int เพิ่ม ( CObject * newElement );
โยน ( CMemoryException );
ส่งกลับค่า
ดัชนีขององค์ประกอบเพิ่มเติม?
พารามิเตอร์
newElement
ตัวชี้CObjectเพื่อเพิ่มลงในอาร์เรย์นี้?
หมายเหตุ
เพิ่มองค์ประกอบแบบใหม่ส่วนท้ายของอาร์เรย์ เติบโตอาร์เรย์ โดย 1 ถ้ามีการใช้SetSizeมีค่าnGrowByที่มีมากกว่า 1 แล้วหน่วยความจำพิเศษอาจสามารถจัดสรร อย่างไรก็ตาม ขอบเขตบนจะเพิ่มขึ้น โดยเฉพาะ 1?
ตารางต่อไปนี้แสดงฟังก์ชันสมาชิกอื่น ๆ ที่คล้ายกับCObArray::Add?
| คลาส | ฟังก์ชันของสมาชิก |
| CByteArray | int เพิ่ม (ไบต์ newElement); nbsp โยน ( CMemoryException );(&N) |
| CDWordArray | int เพิ่ม (DWORD newElement ); nbspโยน ( CMemoryException );(&N) |
| CPtrArray | int เพิ่ม (โมฆะ * newElement ); nbspโยน ( CMemoryException );(&N) |
| CStringArray | int เพิ่ม (LPCTSTR newElement ); nbspโยน ( CMemoryException );(&N) |
| CUIntArray | int เพิ่ม (UINT newElement ); nbspโยน ( CMemoryException );(&N) |
| CWordArray | int เพิ่ม (WORD newElement ); nbspโยน ( CMemoryException );(&N) |
ตัวอย่าง
ดูรายชื่อของCObList::CObList CAge ชั้นที่ใช้ในตัวอย่างของคอลเลกชันทั้งหมด?
/ / ตัวอย่าง CObArray::Add
nbsp อาร์เรย์ CObArray
อาร์เรย์เพิ่ม (กรงใหม่ (21)); / / องค์ประกอบที่ 0
อาร์เรย์เพิ่ม (กรงใหม่ (40)); / / องค์ประกอบที่ 1
#ifdef _DEBUG
afxDump.SetDepth (1);
afxDump << "เพิ่มตัวอย่าง: " << & อาร์เรย์ << "\n"
#endif
ผลลัพธ์ได้จากโปรแกรมนี้มีดังนี้:
เพิ่มตัวอย่าง: การ CObArray กับองค์ประกอบที่ 2
nbsp [0] =ในกรงที่ $ 442A 21
[1] =ในกรงที่ 4468 $ 40(&N)
ภาพรวม CObArray |nbsp สมาชิกของคลาส| แผนภูมิของลำดับชั้น(&N)
ดูเพิ่มเติมnbspCObArray::SetAt, CObArray::SetAtGrow, CObArray::InsertAt, CObArray::operator [](&N)