Class describe properties and method of an object.In other world class is a description of an object.Class is a blueprint or a set of instruction to build a specific type of object.
class class_name { field or data member or method field or data member or method field or data member or method }
Object is self-contained component which consists of methods and properties.In C++ is an object, and almost everything has attributes and methods.
class_name object_name;
C++ Class And Object Example-
#include class Employe { public: int id; string name; void insert(int i, string n) { id = i; name = n; } void display() { cout<< id << " " << name << endl; } }; void main() { Employe e1; Employe e2; e1.insert(1, "Rahul"); e2.insert(2, "Mohit"); e1.display(); e2.display(); }
output:
1 Rahul
2 Mohit