Introduction to Programming
Object Oriented Programming
Summer 24-25, Section B6
Dr. Nazib Abdun Nasir
Assistant Professor, CS, AIUB
[Link]@[Link]
Outline 2
Object Oriented Programming
Key Concepts of OOP in C++
Core Principles
Advantages of OOP
Provided Materials
Dr. Nazib Abdun Nasir [Link]@[Link]
Object Oriented Programming 3
Object-Oriented Programming (OOP) in C++ is a programming paradigm that
organizes software design around data, or "objects," rather than functions
and logic.
This approach allows developers to model real-world entities more
intuitively and effectively.
Dr. Nazib Abdun Nasir [Link]@[Link]
Key Concepts of OOP in C++ 4
Class: A class serves as a blueprint for creating objects. It encapsulates data
members (attributes) and member functions (methods) that operate on the
data. For example, a Car class may have attributes like color and model, and
methods like accelerate() and brake().
Object: An object is an instance of a class, representing a specific entity with
its own state and behavior. For instance, myCar could be an object of the Car
class with specific values for its attributes.
Dr. Nazib Abdun Nasir [Link]@[Link]
Core Principles 5
Encapsulation: Bundling data and methods that operate on the data within a
single unit (class), restricting access to some components.
Abstraction: Hiding complex implementation details while exposing only
essential features.
Inheritance: Allowing a new class to inherit properties and methods from an
existing class, promoting code reusability.
Polymorphism: Enabling a single interface to represent different underlying
forms (data types).
Dr. Nazib Abdun Nasir [Link]@[Link]
Advantages of OOP 6
Modularity: Code is organized into discrete classes, making it easier to
manage and understand.
Reusability: Classes can be reused across programs, reducing redundancy.
Maintainability: Changes in one part of the code can be made
independently of others, simplifying updates and debugging.
Dr. Nazib Abdun Nasir [Link]@[Link]
Provided Materials
OBJECT-ORIENTED PROGRAMMING
(OOP) BASIC CONCEPTS IN C++
WHAT IS OOP ?
Object-oriented programming (OOP) is a programming paradigm
based upon objects that aims to incorporate the advantages of
modularity, reusability, and maintainability.
PROCEDURAL OOP
Focus is on the sequence of Focus is on the Data rather than
operations rather than the Data. sequence of operations.
Writing a series of steps become We can easily model large real-world
complex for large programs. concepts using OOP.
Poor maintainability and reusability OOP approach offers great reusability
and maintainability
FUNDAMENTAL PRINCIPLES OF OOP
COMPONENTS OF OOP
Class
Object Encapsulation
OOP Concepts
Abstraction
Polymorphism
Inheritance
What is an Object ?
Name
Identity It gives a unique name to an object.
Age of
Color Dog
State It is represented by attributes of an object. Bark
Sleep
Behavior It is represented by methods of an object.
Dog Object
What is a Class ?
• A class is a set of instruction. Member
Variables Methods
• It is also referred as blueprint.
WRITING A CLASS IN C++ CREATING OBJECT
Class Name
class Dog { // Creating Object
// Properties or Member Variables Dog maltese;
public:
String breed; //Accessing variables and methods
String size; [Link] = "Maltese";
[Link] = "Small";
// method
void run() { [Link]();
Cout<<"Running . . .";
}
}
Encapsulation
Encapsulation is the act of wrapping up of attributes(represented by data members) and
operations (represented by functions) under one single unit (represented by class).
Class
Public
members
Outside
Code
Private
members
References
Excluding my slides, the remaining slides were prepared by Mr. Rifat Mahmud.
My OOP slides are based on my existing knowledge.
Online Website Research.
Dr. Nazib Abdun Nasir [Link]@[Link]