11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14Point and Stare at ObjectsIn This Chapter Examining the object of arrays of objects Getting a few pointers on object pointers Strong typing — getting picky about our pointers Navigating through lists of objectsC++ programmers are forever generating arrays of things — arrays ofints, arrays of floats, so why not arrays of students? Students stand inline all the time — a lot more than they care to. The concept of Studentobjects all lined up quietly awaiting their name to jump up to perform somemundane task is just too attractive to pass up.Defining Arrays of and Pointersto Simple ThingsAn array is a sequence of identical objects much like the identical houses ona street that make up one of those starter neighborhoods. Each element inthe array carries an index, which corresponds to the number of elementsfrom the beginning of the array — the first element in the array carries anoffset of 0.C++ arrays are declared by using the bracket symbols containing the numberof elements in the array:int array[10];// declare an array of 10 elementsThe individual elements of the array can be accessed by counting the offsetfrom the beginning of the array:array[0] = 10;array[9] = 20;// assign 10 to the first element// assign 20 to the last element

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!