Hey, I have a question. I was writing a custom Array type class. In my template declaration I use the type name as DataType. I was making an attempt at creating an insert method, which takes a DataType argument and the index to insert at. I originally had this code:
void insert(DataType p_item, int p_index)
{
int index;
for(index = m_size-1;index>p_index;index--)
{
m_array[index] = m_array[index-1];
}
m_array[p_index] = p_item;
}
Where m_array is the created array, and m_size is it's size. But it was unable to insert into an array which was full, because of how I tried to solve the problem.
So I ended up simplifying it completely:
void insert(DataType p_item, int p_index)
{
DataType m_item;
m_array[p_index] = m_item;
m_array[p_index] = p_item;
}
My question is, what value will the m_item default too? Will this cause problems in the future? When I printed out the array to test it(before I reassigned p_item to the array), it printed an empty space.