(1) Your deleteEven function is supposed to return an int, but you don't return anything.
(2)
numbers is not a pointer to a dynamically allocated array. It's simply a member variable of an ordinary C-style array. You should not call delete on this.
(3) Likewise, you can't overwrite the whole array with an assignment (line 45). You must loop through each element to copy it over.
(4) You should, however, eventually be calling delete[] on the 'temp' object that you new[]'d.
(5) You declare a variable called 'j' on line 28 but never initialize it.
(6)
1 2 3
|
for (int i=index; i<8; i++) {
numbers[i] = numbers[i+1];
}
|
This will call numbers[7] = numbers[8], which goes out of bounds of your numbers array.
You should turn on warnings on your compiler; there will probably be several
51:5: warning: control reaches end of non-void function [-Wreturn-type]
39:9: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
In function 'int main()':
15:37: warning: iteration 3u invokes undefined behavior [-Waggressive-loop-optimizations]
14:9: note: containing loop |
Your size can, at most, be 8. So you don't need to dynamically create an array here. Just create an array of size 8, and use some or all of those indices.