How many instances of a class can be declared?

How many instances of a class can be declared?

a) Only one
b) Ten
c) As many as required
d) None

Answer:

c) As many as required

Explanation:

In C++, you can declare as many instances (objects) of a class as needed. Each instance of a class has its own set of data members, allowing each object to hold different values independently of other objects. This is a key feature of object-oriented programming, enabling the creation of multiple objects that share the same structure but can have different states.

Understanding how to create and manage multiple instances of a class is essential for writing object-oriented programs in C++.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

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

Scroll to Top