Transcript Training

OBJECT-ORIENTED
PROGRAMMING (OOP) WITH
C++
Instructor: Dr. Hany H. Ammar
Dept. of Electrical and Computer
Engineering, WVU
Introduction To OOP

OOP is an approach for writing software in which data and behavior are
packaged together as classes whose instances are objects

A class is a named software representation for an abstraction, where

An abstraction is a named collection of attributes and behavior relevant to
modeling a given entity for some particular purpose,

An object is a distinct instance of a given class that is structurally identical to
all other instances of that class.

Software code in OOP is written to define classes, instantiate objects, and
manipulate these objects.
Abstraction
Mapping Abstractions
Class Structure
Object Structure
Summary of the Course
This is a project-based, lab-oriented course aimed at learning the fundamentals
of Object-Oriented Program development in C++. Topics include
1. Object-Oriented programming concepts
2. The C++ Program Structure
3. The C++ Data Types
4. Functions, Scope, and the Free Store
5. The C++ class
6. Operator Overloading
7. Class Derivation and inheritance
8. Multiple inheritance, and polymorphism
9. Object-Oriented Analysis and Design
10 OOP testing techniques
Basic Concepts of OOP
1. Simulating the behavior of objects ( e.g...., an array of data structures can be
sorted or indexed, a stack can be used for pushing or popping data). OOP
concepts are based on the concepts of Computer Simulation.
2. Abstract Data Types (ADTs) consists of {data structures + operations or
functions}, (e.g....., a Matrix can be defined as an ADT consisting of a 2dimensional array + the operations of inverse, transpose, and other operations
and methods which can be applied to objects of type Matrix).
3. Hiding implementation details using encapsulation, where each class of objects
consists of a private section, a protected section, and a public section. Data
structures and functions in a private class section can only be accessed locally
within the class. The protected class section can also be accessed by derived
classes.
Basic Concepts of OOP
4. Reusing code through inheritance. A hierarchy of classes allow derived classes
to inherit code (i.e.., data structures and functions) defined in parent classes.
For example,
Matrix
Singular
Nonsingular
Square
Basic Concepts of OOP
5. Function and Operator Overloading. A class may contain several functions
with the same function name but with different arguments, or operators such as
+ , -, *, and / are used to define operations on different objects, e.g.... matrix
multiply can be defined as A * B, where A and B are objects of type Matrix.
6. Polymorphism where objects of distinct classes can be manipulated using only
knowledge of their common properties without regard for their exact class.
Basic Concepts of OOP
* The dynamic binding mechanism determines the type of the object and maps the
invocation to the correct method in class X, if the object is of class X, or to the
correct method in class Y, if the object is of class Y (e.g., the function F() could be a
print() function, and the algorithm is unaware of the exact type of object to be printed, it
invokes the function using a base class of classes X and Y).
Basic Concepts of OOP
7. The use of templates to design generic classes of objects
Basic Concepts of OOP
8. The use of friend functions and friend classes to access all the functions and
data types of other classes (violates the concept of information hiding; adds
needed flexibility and should only be used when necessary).
9. Design using Class Libraries and Design Patterns