2.2.7.1.6 Array::RemoveAt

Description

It removes the object at the supplied index from the array. If owner, the object will be destroyed.

Syntax

BOOL RemoveAt( int nIndex )

Parameters

nIndex
[input] the index of the object to remove.

Return

Returns a boolean indicating success or failure of the requested operation

Examples

EX1

#include <Array.h>
struct PERSON
{
	int nID;
};
void Array_RemoveAt_ex1()
{
	Array<PERSON&> arp(true); //is owner
	for ( int ii = 0; ii < 4; ii++ )
	{
		PERSON* tp = new PERSON;
		tp->nID = ii + 1;
		arp.Add(*tp);
	}
	
	if ( arp.RemoveAt(0) ) //remove the first item
	{
		for ( ii = 0; ii < arp.GetSize(); ii++ )
		{
			//the item with nID value as 1 is removed and can not be printed now.
			printf("PERSON %d's ID is : %d\n", ii + 1, arp.GetAt(ii).nID);
		}
	}	
}

Remark

See Also

Header to Include

Array.h