0% found this document useful (0 votes)
15 views3 pages

Oops

Object-Oriented Programming (OOP) structures programs using classes and objects, where a class serves as a blueprint for creating objects with specific properties and functions. An object is a real instance derived from a class, containing actual data and capable of utilizing the class's functions. The document also outlines the four pillars of OOP: encapsulation, abstraction, inheritance, and polymorphism.

Uploaded by

royalminigaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Oops

Object-Oriented Programming (OOP) structures programs using classes and objects, where a class serves as a blueprint for creating objects with specific properties and functions. An object is a real instance derived from a class, containing actual data and capable of utilizing the class's functions. The document also outlines the four pillars of OOP: encapsulation, abstraction, inheritance, and polymorphism.

Uploaded by

royalminigaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

C++ OOPS

Object-Oriented Programming (OOP) is a way to structure programs using


objects — just like things in real life (like a car, dog, or student).

1. What is a Class?
A class is like a blueprint or template for creating things (objects).
 It defines what properties (variables) and what actions (functions)
an object will have.
 Think of it like a design or plan.
Real-Life Example:
 Class: Car
 Properties: color, brand, speed
 Functions: start(), stop(), drive()
But this class doesn't represent any actual car — just the idea of a car.

2. What is an Object?
An object is a real item created using a class.
It has actual values inside it.
 You can create many objects from one class.
 Each object has its own data and can use the class functions.
Real-Life Example:
From class Car, you can create:
 Car c1 = BMW, red
 Car c2 = Audi, black
Each car (object) is based on the same class (design) but is a real, usable
thing.
#CODE:-
#include <iostream>
using namespace std;

// Creating a class
class Student {
public:
string name;
int age;

void introduce() {
cout << "Hello, my name is " << name << " and I am " << age
<< " years old." << endl;
}
};

int main() {
// Creating objects of the class Student
Student s1; // object 1
s1.name = "Pawan";
s1.age = 15;
s1.introduce(); // call function

Student s2; // object 2


s2.name = "Ravi";
s2.age = 14;
s2.introduce();

return 0;
}

// summary

Term Definition Example

Blueprint/template for
Class Car, Student, Animal
objects

Objec Real-world entity from a A red BMW, Pawan


t class (student)

Four Pillars of OOPs


1. Encapsulation
2.Abstraction
3. Abstraction 4. polymorphism

You might also like