Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

OOPS NOTES

Rating
-
Sold
-
Pages
26
Uploaded on
08-06-2025
Written in
2024/2025

Providing all class notes

Institution
Course

Content preview

​Here’s a detailed explanation of the concepts you mentioned:


1. Polymorphism


Polymorphism allows one interface to be used for multiple
purposes, enabling the same function or operator to behave
differently based on the input or context.


a. Function Overloading


Multiple functions with the same name but different parameter
lists (different types or numbers of arguments).


Example:


void print(int i) { cout << "Integer: " << i << endl; }
void print(double d) { cout << "Double: " << d << endl; }
void print(string s) { cout << "String: " << s << endl; }




b. Operator Overloading


Operators are redefined to work with user-defined types (e.g., + for
complex numbers).


Example:

,class Complex {
int real, imag;
public:
Complex(int r, int i) : real(r), imag(i) {}
Complex operator + (const Complex& obj) {
return Complex(real + obj.real, imag + obj.imag);
}
};




c. Virtual Functions and Dynamic Polymorphism


Virtual functions: Member functions declared with the virtual
keyword. They allow derived class functions to override base class
functions.


Dynamic polymorphism: Achieved through virtual functions using
runtime binding.


Example:


class Base {
public:
virtual void show() { cout << "Base class" << endl; }
};
class Derived : public Base {
public:
void show() override { cout << "Derived class" << endl; }
};

, 2. Abstract Classes and Pure Virtual Functions


Abstract Class: A class that cannot be instantiated and often serves
as a blueprint for other classes.


Pure Virtual Function: Declared by assigning = 0 in a class, forcing
derived classes to implement the function.


Example:


class AbstractBase {
public:
virtual void display() = 0; // Pure virtual function
};
class Derived : public AbstractBase {
public:
void display() override { cout << "Derived implementation" <<
endl; }
};




3. Encapsulation and Data Hiding


Encapsulation: Wrapping data and methods into a single unit
(class).


Data Hiding: Restricting access to internal details of a class using
access specifiers like private and protected.

Written for

Institution
Course

Document information

Uploaded on
June 8, 2025
Number of pages
26
Written in
2024/2025
Type
Class notes
Professor(s)
Oops
Contains
All classes

Subjects

$28.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
rohit14

Get to know the seller

Seller avatar
rohit14 MDU
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
10 months
Number of followers
0
Documents
9
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions