12.14 END OF CHAPTER PROGRAMS

So far we have studied pointers and dynamic memory allocation. The most appropriate application of it is class Vector.

12.14.1 Class Vector

In our opinion, “array” is the most powerful data structure. However, its size is fixed. Normally, in a class, there are sixty students. You may develop an appropriate array to store their data. If tomorrow, five more students will be additionally enrolled; program cannot be used.

Vector is an array whose dimension can increase. You will ask me what about decrease? Well a large vector can store less data without any problem. If one can write a code to increase the capacity, he/she can easily write a method to reduce it.

Problem: Write a program to develop class Vector for storing ...

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.