0% found this document useful (0 votes)
3 views2 pages

OOP Midterm Notes

The document provides midterm notes on Object-Oriented Programming (OOP), covering key concepts such as encapsulation, inheritance, polymorphism, and abstraction. It explains the definitions and examples of classes, objects, derived classes, constructors, and destructors in C++. The notes emphasize the benefits of OOP in improving modularity, code reuse, and maintainability.

Uploaded by

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

OOP Midterm Notes

The document provides midterm notes on Object-Oriented Programming (OOP), covering key concepts such as encapsulation, inheritance, polymorphism, and abstraction. It explains the definitions and examples of classes, objects, derived classes, constructors, and destructors in C++. The notes emphasize the benefits of OOP in improving modularity, code reuse, and maintainability.

Uploaded by

Rao Anas
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Object-Oriented Programming (OOP) — Midterm Notes

1. Introduction to OOP
A programming paradigm that models software using classes and objects to improve modularity,
reuse, and maintainability.
Key Points

• Encapsulation, Inheritance, Polymorphism, Abstraction

• Models real-world entities

• Supports code reuse and scalability

2. Class
A user-defined type that groups data members and member functions.
Example (C++)
class Car {
public:
string color;
int speed;
void start(){ cout << "Car started"; }
};

3. Object
An instance of a class used to access its members.
Example (C++)
Car c1;
[Link] = "Red";
[Link] = 120;
[Link]();

4. Derived Classes (Inheritance)


Mechanism where a class acquires properties and behavior of another class.
Syntax (C++)
class Parent { public: void show(){ cout << "Parent"; } };
class Child : public Parent { public: void display(){ cout << "Child"; } };

Usage
Child c;
[Link]();
[Link]();

5. Constructor and Overloading


A special member function invoked automatically when an object is created to initialize data
members.
Example (C++)
class Car {
public:
Car(){ cout << "Default"; }
Car(string c){ cout << c; }
};
6. Destructor
A special member function invoked automatically when an object goes out of scope to release
resources.
Syntax (C++)
class Car {
public:
~Car(){ cout << "Destroyed"; }
};

You might also like