We do not manipulate the data directly. We can do so only by using functions and objects Imagine you want to build an application to keep track of all the books.

The data has to be considered in OOP Here, our data is all about books. Therefore, the first object type is a book.

Now, we have designed the object in such a way that all the data can be stored in a state for any further manipulation.

In C++, the design of an object is done by creating a class. For programmers, a class is similar to (a blueprint of a building) to an architect.

In case, if you give those books to others then, the person also becomes an object. Therefore, you create a person class.

The tracking app can then create a new object of a person’s class and fill it with data about your friend.

C++ Program to Create Multiple Objects for a class program

using namespace std;
class Summer{ 
int x;
public: void read();
void print(); };
void Summer :: read() { 
cout<<"Enter any integer value "<<endl;
void Summer :: print(){ 
cout<<"The value is :"<<x<<endl; } 
int main(){ 
Summer s1,s2,s3; 
return 0;

Output:-Enter any integer value 234
Enter any integer value 456
Enter any integer value 789
The value is :234
The value is :456
The value is :789

Explanation of the program

In this program, the read() and print() member functions are shared by all the objects of the type sample. Whereas in the case of data members, each object i.e. s1, s2, and s3 has its own copy.

This article is written by our awesome writer
Comments to: How to Create Multiple Objects for a class In C++

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password