Coupon Accepted Successfully!


Array of Objects Using Constructors

An array is a collection of similar data types. We can also create an array of objects. The array elements are stored in contagious memory y locations. An array of objects is one of the most important data structures when data is itself an object. Program on it is illustrated using constructor.


9.9 Write a program to declare array of objects by using constructor.

Explanation: The above program is generalized and can be extended to large number of objects. We have created an array of objects c[3] in the above program. The object c[3] initializes three names of the states and their capitals through keyboard, and the object c[3] calls the constructor three times.

Test Your Skills Now!
Take a Quiz now
Reviewer Name