CPP Object Class

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations.

CPP Class:

A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods.


class ClassName:







CPP Object:

Anything that has state and behavior can be termed as an Object, be it physical or logical. An Object is an entity mentioned in OOPs concept and is frequently found in CPP codes.

Creating an object in CPP is similar as calling a function. The objects attributes can then be accessed by using the object name prefix.


#include <iostream.h>
using namespace std;
class Employees
string Name;  
float Salary;
void insert(string n, float s)    
Name = n;    
Salary = s;  
void details()
cout << "Employee Name : " << Name << endl;
cout << "Employee Salary: " << Salary << "\n\n";
int main()
Employees e1;   
Employees e2; 
e1.insert("Khush", 10000);    
e2.insert("Raam", 20000);    
return 0;


Employee Name : Khush                                 
Employee Salary: 10000                               
Employee Name : Raam                                                 
Employee Salary: 20000
Please follow and like us:
Content Protection by DMCA.com