Array Problems/Special Cases
- An Out of Bounds array index is an index value that is either less than zero or greater than or equal to the declared size of an array.
- There is no way to automatically detect this at run time.
- You MUST do it by hand.
- Before you use an array index, make sure that it is in bounds.
- If your program behaves in an unpredicted way, or crashes and it includes an array, check for out of bounds array index errors.
- If you are lucky your program will crash from an array out of bounds error.
- If you are not, it will just run.
- Arrays do not support aggregate operations.
- Input and output on an array must be done by "hand"
- cout << array is not valid.
- Comparison does not work as you expect
- Comparison uses the base address, not an item by item comparison.
- No assignment operator
- No arithmetic
- Passing to functions
- Arrays are always passed by reference.
- This is because a pass by value would require all of the data to be copied.
- And that is expensive for large arrays.
- But you can Function (const int array[]); in c++
- Not new, but arrays are not iniltalized