A couple things. The first doesn't really matter much, but you are using manual pointer arithmetic when indexing is shorter, and more clear. Why use
*(m_array + i)
when you can just do
m_array[i]
Some times it makes sense to use manual pointer arithmetic (IE when you are incrementing the pointer without using a variable (example: ++m_array) but here it just brings down readability.
The second problem is VERY big.
You've created a [probable] memory leak.
You use the false assumption that a dynamically allocated array of 1 element can be deleted without using delete []. That is not true!
When you dynamically allocate an array, two things are actually allocated. The array itself and some way of keeping track of the size of the array so that when you delete it, it will be deleted fully. Using delete [] checks that value, deletes the corresponding amount of data, but also deletes the data that was used to keep track of the size of the array internally.
The way this is usually done by the compiler is the extra data is placed before the array in memory.
So
m_array = new Datatype[Amount];
will actually allocate something similar to this type (pseudo-code):
struct
{
inttype SizeOfArray; // = Amount
Datatype Array[Amount];
}
//Where inttype would be an integer type of size pointer to primitive built-in-type
When you call new, it will return a pointer to the Array member (not the beginning of the struct) so that you can use the array as normal.
Then, when you call delete [] on it, it knows to go back sizeof(inttype) in memory to check how much to delete but it also has to delete itself as well.
If you call delete without the brackets, then you totally miss the extra data.
Code:
if(m_size > 1)
{
delete [] m_array;
}
else
{
delete m_array;
}
Should just be
delete [] m_array;
plain and simple. Otherwise you'll have problems in the future.