array1.AddReference(&obj11,false);// Do not free this object when the array is freed, This object declared on the stack, so it'll be free by C++
array1.AddReference(newTestObjInt(12,&m_destructor_called12),true);// Free this object. C++ doesn't keep any reference of new allocated object. So it won't be freed by C++
array1.AddReference(newTestObjInt(13,&m_destructor_called13),true);// Free this object. C++ doesn't keep any reference of new allocated object. So it won't be freed by C++
array1.AddReference(obj14,false);// We keep a reference an obj14. Let's not ask the array to free it.
if(array1[0].m_v!=11)return1;
if(array1[1].m_v!=12)return2;
if(array1[2].m_v!=13)return3;
if(array1[3].m_v!=14)return4;
array1.RemoveAtIndex(1);
if(array1[1].m_v!=13)return5;
}
// Here the array and objects we added saying true as second parameter of AddReference.