CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Cyber Safety and Ethics · 8 min · free

Basic Concepts of OOP in C++

8 min4 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

Object oriented programming builds a program from objects that keep data and functions together, made from a class blueprint. Its key ideas are class, object, abstraction, encapsulation, inheritance and polymorphism.

Follows the syllabus of: NIOS Senior Secondary Computer Science (330)

On screen in this lesson

Two ways to write programs

Procedural: a program is a list of functions
Data moves freely between functions
Object oriented: a program is a set of objects
Each object keeps its data and functions together

Object: a real thing

ObjectDataFunctions
A studentroll, marksstudy()
A bank accountbalancedeposit()
A mobile phonebatterycall()

Class: the blueprint

A class is a design or template
An object is a real copy made from it
One class can make many objects
A class is a user-defined data type

Abstraction

Show only the essential features
Hide the complex inner details
Example: you press a switch, not wire the fan
In C++: public functions hide the inner work

Encapsulation

Wrap data and functions into one unit
The unit is the class
Data is kept private, safe from outside
Outside code uses public functions only

Inheritance

A new class reuses an existing class
Existing class: base class or parent
New class: derived class or child
Saves rewriting the same code

Quick answers

A class has 3 data members and you make 5 objects. How many marks values exist?

5, one per object.

What does encapsulation do?

Wraps data and functions into one unit, the class.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. C is a powerful language, so why did its creator build C plus plus on top of it? The answer is a new way of thinking, called object oriented programming. Today we learn its six key ideas, why C plus plus added them, and the exact words exams expect.

There are two main styles of programming. In the procedural style, used by C, a program is a list of functions, which are named blocks of steps. The data is kept separate, and any function can change it. In the object oriented style, a program is built from objects. Each object keeps its own data and the functions that work on that data together. We write object oriented programming as OOP for short.

An object is anything real that has some data and can do some work. A student has a roll number and marks, and a student can study. A bank account has a balance, and money can be deposited into it. A mobile phone has a battery level, and it can make a call. In OOP, the data is called attributes, and the functions are called methods or member functions.

Now, where do objects come from? A class is a design, like the plan of a house drawn by an architect. An object is a real house built from that plan. From one class, we can make many objects, just as one plan can build many houses. Because we create the class ourselves, a class is called a user defined data type.

Here is a tiny class in C plus plus. The keyword class starts it, and its name is Student. It has one data member, marks. In main, we create two objects, riya and aman, from the same class. Each object has its own marks, reached with a dot. Seventy two plus sixty five prints one hundred thirty seven.

The third idea is abstraction. Abstraction means showing only what the user needs, and hiding the complicated details. Think of a ceiling fan. You press the switch, and you do not need to know how the motor and wires work. In C plus plus, a class gives public functions to use, while its inner work stays hidden.

The fourth idea is encapsulation, which means wrapping up. Encapsulation wraps the data and the functions that use it into one unit. In C plus plus, that unit is the class. The data is usually made private, so code outside the class cannot touch it directly. Outside code must use the public functions, and this protection is called data hiding.

Here, a Wallet class keeps its balance, bal, private. Members of a class are private by default. In main, the object is named w, short for wallet. Main cannot write w dot bal directly, because that would be a compile error. Instead, it calls the public function add, with one hundred ninety nine rupees. Then get returns the balance, so it prints one hundred ninety nine.

The fifth idea is inheritance. Inheritance lets a new class take the data and functions of an existing class. The existing class is called the base class, or parent class. The new class is called the derived class, or child class. Just as a child inherits features from parents, the derived class reuses the base class code, so we do not rewrite it.

Let us look at an example. Vehicle is the base class, and every vehicle has wheels and can move. Car is derived from Vehicle, so it gets wheels and move, and adds its own music system. Bus is also derived from Vehicle, and it adds a conductor. The common code is written only once, in Vehicle.

The sixth idea is polymorphism. The word comes from Greek, where poly means many and morph means forms. So polymorphism means one name with many forms. For example, a function named area works differently for a circle and for a square. In C plus plus, polymorphism happens at compile time or at run time, and we study both in a later lesson.

Here is polymorphism in a simple form, called function overloading. Two functions share the name area. The first takes one side and returns the area of a square. The second takes a length and a breadth and returns the area of a rectangle. C plus plus picks the right one by counting the arguments. So it prints sixteen, then twenty.

Now, why did C plus plus add OOP to C? Bjarne Stroustrup started it at Bell Labs in 1979, first calling it C with Classes. As C programs grew to thousands of lines, they became hard to manage and fix. Global data could be changed by any function, so one mistake could spread everywhere. Real things like students and accounts were hard to model with separate data and functions. And reusing code often meant copying and pasting it.

This table is a favourite exam question. C is procedural, while C plus plus supports both procedural and object oriented styles. C focuses on functions, and C plus plus focuses on objects and their data. C gives little data security, but C plus plus offers data hiding. C reuses code by copying, and C plus plus reuses it through inheritance. C follows a top down approach, while C plus plus follows a bottom up approach.

Exams also use a few more OOP words. Data hiding means keeping data private, and encapsulation achieves it. Message passing means objects talk to each other by calling functions. Dynamic binding means the function to run is decided while the program runs, and it supports polymorphism. Reusability means using existing code again, mainly through inheritance.

Pause and predict. A class Student has three data members, and one of them is marks. We create five objects from this class. How many separate marks values exist in memory? The answer is five, because every object gets its own copy of the data members.

Let us revise what we learned today. A class is a blueprint, and an object is a real copy made from it. Abstraction shows only the essentials and hides the details. Encapsulation wraps data and functions into one unit, the class. Inheritance lets a derived class reuse a base class. And polymorphism means one name with many forms. Learn these definitions with one everyday example each, because exams ask for both.

Courses that teach this

CourseUnit
NIOS Senior Secondary Computer Science (330)Module 3: Programming in C++

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →