What are objects ? What is common between all objects of a class ?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Objects are physical or conceptual things that are found in the universe. Objects are thought of having state associated with them. E.g. state of an account would be the account balance; the state of a clock would be the time.
In object oriented terminology a class is just a plain structure and an object is an instance of a structure. A class is a blueprint that does not take memory however when a class is instantiated by creating an object of that class then each such object takes up memory space.
All objects of a class have identical structure however each object will have its own private data. E.g. a class student will have multiple instances of students where each student instance will have distinct values for their attributes.
Each object will have its own memory with its data however all the objects of a class share the member functions of a class.
E.g. we will define a class called account and create two objects of this class.
class Account
{
private:
double account_balance;
int account_no;
public:
double calculateInterest();
void deposit(double);
double withdraw();
}
Create objects of account in the following way:
Account account1, account2… accountn;
Related Articles
- What are static Data and Static Member Functions in C++ ?
- What are classes ? How are they defined ?
- Explain Composition in C++ with an example
- Explain the Concept of Data Abstraction and Data Encapsulation in Object Oriented Programming (OOPS)
- What are Constructors and Destructors in C++ ?


