13-Arrays-4up

first and second are different pieces of memory

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t pieces of memory, Variables: Array Objects: therefore first != second int first 7 24/07/11 0 1 1 2 2 3 int second 9 20 int second 24/07/11 6 : Array Objects: 0 2 3 outOfBounds.cpp ì const int SIZE = 10; int first = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}; int second[SIZE]; for (int i = 0; i < SIZE; i++) { second[i] = first[i]; } int first 2 Comparing arrays To copy an array... you must copy each element. Variables: 1 int price 24/07/11 ì C++ does not do... automatic bounds checking. on array index operations. : Out of bounds access... use memory which isn't part of the array. : Could be anything else in memory! int price[4]; price[0] = 10; // price[4] = 11; // price[-1] = 12; // 1 2...
View Full Document

Ask a homework question - tutors are online