O'Reilly logo

C++ For Dummies, 7th Edition by Stephen R. Davis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13

Point and Stare at Objects

In This Chapter

arrow Examining the object of arrays of objects

arrow Getting a few pointers on object pointers

arrow Strong typing — getting picky about our pointers

arrow Navigating through lists of objects

C++ programmers are forever generating arrays of things — arrays of ints, arrays of doubles — so why not arrays of students? Students stand in line all the time — a lot more than they care to. The concept of Student objects all lined up quietly awaiting their names to jump up to perform some mundane task is just too attractive to pass up.

Declaring Arrays of Objects

Arrays of objects work the same way arrays of simple variables work. (Chapter 7 goes into the care and feeding of arrays of simple — intrinsic — variables, and Chapters 8 and 9 describe simple pointers in detail.) Take, for example, the following snippet from the ArrayOfStudents program:

  // ArrayOfStudents - define an array of student objects//                   and access an element in it. This//                   program doesn't do anything#include <cstdio>#include <cstdlib>#include <iostream> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required