0% found this document useful (0 votes)
25 views39 pages

C++ Presentation 3

This document provides an introduction to object-oriented programming prepared by Group 2 for a computer programming course at the University of Gondar Institute of Technology, Department of Biomedical Engineering. The course instructor is Mr. Kindu and the date is January 16, 2020. The group members and their student IDs are listed. The document then covers the key differences between procedural and object-oriented programming, main features of OOP including encapsulation, inheritance, polymorphism and abstraction. It also provides an overview of objects and classes in OOP.

Uploaded by

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

C++ Presentation 3

This document provides an introduction to object-oriented programming prepared by Group 2 for a computer programming course at the University of Gondar Institute of Technology, Department of Biomedical Engineering. The course instructor is Mr. Kindu and the date is January 16, 2020. The group members and their student IDs are listed. The document then covers the key differences between procedural and object-oriented programming, main features of OOP including encapsulation, inheritance, polymorphism and abstraction. It also provides an overview of objects and classes in OOP.

Uploaded by

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

University of Gondar

Institute of Technology
Department of Biomedical Engineering

Introduction to Computer Programming


Object-Oriented Programming
Prepared by Group 2

Course Instructor: Mr. Kindu


Date: January 16 2020
Group 2 Members:
Name Id Number
1. Melaku Dessie 02950/11
2. Mulugeta Agumas 02914/11
3. Mulusew Desale 03520/11
4. Nathnael Muluken 03681/11
5. Oliyad Gezahegn 03678/11
6. Samrawit Zerihun 02938/11
7. Seble Getaw 03268/11
8. Solomon Fisseha 03178/11
9. Surafel Yimam 03243/11
10. Tadilo Guadie 03626/11
In this lecture:
• Introduction
• Procedure Oriented Vs. Object Oriented
• Main Features of OOP
• Overview of Object and Class
Object Oriented Programming
• Object-oriented programming
(OOP) is a software programming
model constructed around objects.
• The focus of OOP languages is not on
structure, but on modeling data.
• Programmers code using “blueprints”
of data models called classes.
• Examples of OOP languages include
C++, Visual Basic.NET and Java.
Cont.
• Object – Unique programming entity
that has methods, has attributes and
can react to events.
• Method – Things which an object
can do; the “verbs” of objects. In
code, usually can be identified by an
“action” word -- Hide, Show
Cont.
• Attribute – Things which describe
an object; the “adjectives” of
objects. In code, usually can be
identified by a “descriptive” word –
Enabled, BackColor
• Events – Forces external to an
object to which that object can react.
In code, usually attached to an event
procedure
Cont.
• Class – Provides a way to create
new objects based on a “meta-
definition” of an object (Example:
The automobile class)
• Constructors – Special methods
used to create new instances of a
class (Example: A Honda Civic is an
instance of the automobile class.)
Cont.
• OOP languages are diverse, but the
most popular ones are class-based,
meaning that objects are instances
of classes, which also determine
their types.
• Examples of object-oriented
programming languages are C++,
C#, Java, Python, Simula, and
Smalltalk.
Procedural Oriented Vs.
• Procedural oriented programming
(pop) Program in a procedural
language is a list of instruction where
each statement tells the computer to
do something. It focuses on
procedure (function) & algorithm is
needed to perform the derived
computation.
Cont.
• Procedures, also known as routines,
subroutines, or functions, simply
contain a series of computational
steps to be carried out. Any given
procedure might be called at any
point during a program's execution,
including by other procedures or
itself.
Vs. Object Oriented
• Object-oriented programming (OOP)
is a programming paradigm based on
the concept of "objects", which can
contain data, in the form of fields
(often known as attributes or
properties), and code, in the form of
procedures (often known as
methods).
Cont.
• OOP is a high-level programming
language where a program is divided
into small chunks called objects
using the object-oriented model,
hence the name. This paradigm is
based on objects and classes.
Cont.
NO. FEATURES OOP POP
1 Definition Is a programming focuses on
approach that focuses procedural
on data rather than the abstractions
algorithm
2 Programs based on the functions. the main program is
the program is divided divided into small
into small chunks called parts
objects which are
instances of classes
3 Accessing access attributes or no such accessing
Mode functions – ‘Private’, mode is required to
‘Public’, and ‘Protected’. access attributes or
functions of a
particular program
Cont.
NO. FEATURES OOP POP
4 Focus focus on the data relies on functions or
associated with the algorithms of the
program program.
5 Execution various functions can follows a systematic
work simultaneously step-by-step
approach to execute
methods and
functions.

6 Data Control the data and functions of data can move freely
an object act like a because each
single entity so function contains
accessibility is limited to different data.
the member functions of
the same class.
Cont.
NO. FEATURES OOP POP
7 Data hiding Is possible in OOP. No easy way for data
hiding.
8 Process follows a bottom-up It takes a top-down
approach for designing a approach to design a
program program
9 Program Is divided into objects Is divided into small
depending on the chunks based on the
problem. functions.
10 Examples Commonly used Commonly used
languages are C++, languages are Pascal
Java, VB.NET and Fortran.
Main Features of OOP
• The Objects Oriented programming
language supports all the features of
normal programming languages.
• In addition it supports some
important concepts and terminology
which has made it popular among
programming methodology.
Cont.
• Encapsulation:
• Incorporation into a class of data &
operations in one package
• Data can only be accessed through
that package
• “Information Hiding”
Cont.
• Inheritance
• Allows programmers to create new
classes based on an existing class
• Methods and attributes from the
parent class are inherited by the
newly-created class
• New methods and attributes can be
created in the new class, but don’t
affect the parent class’s definition
Cont.
• Data Abstraction
Data Abstraction helps to deal with
objects since their important features
and ignore all other details.
Cont.
• Polymorphism
• Creating methods which describe the
way to do some general function
(Example: The “drive” method in the
automobile class)
• Polymorphic methods can adapt to
specific types of objects.
Cont.
• Reusability
• This usage is achieved by the above
explained terminology called as
inheritance.
• Reusability is nothing but re- usage
of structure without changing the
existing one but adding new features
or characteristics to it.
Cont.
• Data Hiding
• The data is hidden inside the class by declaring it
as private inside the class.
• When data or functions are defined as private it
can be accessed only by the class in which it is
defined.
• Object Oriented programming gives importance
to protecting data which in any system.
• This is done by declaring data as private and
making it accessible only to the class in which it
is defined. This concept is called data hiding.
Overview of Object and Class
• Object – An object is basically a
self-contained entity that
accumulates both data and
procedures to manipulate the data.
Objects are merely instances of
classes.
Cont.
• Class – A class, in simple terms, is a
blueprint of an object which defines
all the common properties of one or
more objects that are associated
with it. A class can be used to define
multiple objects within a program.
Cont.
• An Object is an instance of a Class.
When a class is defined, no memory
is allocated but when it is
instantiated (i.e. an object is
created) memory is allocated. A
class is defined in C++ using
keyword class followed by the
name of class.
Cont.
• A class in C++ is the building block,
that leads to Object-Oriented
programming. It is a user-defined
data type, which holds its own data
members and member functions,
which can be accessed and used by
creating an instance of that class.
Cont.
• An object contains properties and
methods which are needed to make
a certain type of data useful. An
object’s properties are what it knows
and its methods are what it can do.
Cont.
• A class is a concept used in object
oriented programming languages
such as C++, PHP, and JAVA. It
provides values for state (member
variables) and implementations of
behavior (member functions,
methods) in programs.
Cont.
• A class is said to be a blueprint of an
object. It is an extensible guide used
for creating objects; it is a subroutine
that creates an object. A class does
not represent the object; it represents
all the information and methods an
object should have. One class can be
used to instantiate multiple objects. It
is considered to be an extended TYPE
declaration.
Cont.
Object Class
Definition An object is defined A class is used in OOP
as any entity that to describe one or
can be utilized by more objects.
using commands in
OOP.
Variables It is a variable. It is the type.
Concept It is an instantiation It is an expanded
of class. concept of data
structures.
Memory Memory is allocated. No memory is
allocated.
Cont.

Object Class
Identifier The ‘object_names’ The ‘class_name’ is a
is an optional list of valid identifier for the
names for objects of class.
this class.
Purpose Data abstraction and grouping of data
further inheritance
Example 1
Output
Example 2
Output
Example 3
Output
References
 Object Oriented Programming in C++,
Robert Lafore
 Absolute C++, 4th Ed, Walt Savitch, Addison
Wesley, 2009
 Programming with Schaum Outlines 2nd
Edition
Thank You

You might also like