Class is a blueprint. Object is a real thing made from that blueprint.
Example: Agar Class "Car ka Naksha" hai, to Object us nakshay se bani hui asli Car hai.
Ek Class se hum jitne marzi Objects bana sakte hain, jaise neeche code me s1 aur s2 banaye hain.
cpp
#include <iostream>
using namespace std;
class Student {
public:
string name;
int rollNo;
void introduce() {
cout << "My name is " << name << endl;
cout << "My Roll No is " << rollNo << endl;
}
};
int main() {
Student s1;
s1.name = "Aliza";
s1.rollNo = 1;
s1.introduce();
Student s2;
s2.name = "Ayesha";
s2.rollNo = 2;
s2.introduce();
return 0;
}
