6.10 ARRAY OF OBJECTS

We have seen an array of basic data type as well as structures. We can have array of objects too. Every element of the array will be an object of a given class. We can use it like any other object. Most of the large programs need an array of objects. Databases depend heavily on arrays of data. When data itself is an object, an array of object becomes the most important data structure.

The critical part here is initialization of objects. Let us study it step by step.

6.10.1 Array of objects – without pointers

Problem: Write a program to study an array of objects without pointers.

Solution: We will first define class Student. Then we will create an array of objects of class student. See Program 6.11.

Program 6.11 Array of ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.