0% found this document useful (0 votes)
189 views

Chapter 1 PDF

This document provides an overview of an Object Oriented Programming course. The course objectives are to understand OOP concepts like inheritance and polymorphism in C++. The course contents will cover classes, inheritance, templates and exception handling. Students will be assessed based on quizzes, assignments, exams and a final exam. Rules require on-time attendance, original work, and no cheating. The reading assignment covers class and object diagrams from a UML book. Assignment 1 is due on September 7th.

Uploaded by

Moiz Ul Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
189 views

Chapter 1 PDF

This document provides an overview of an Object Oriented Programming course. The course objectives are to understand OOP concepts like inheritance and polymorphism in C++. The course contents will cover classes, inheritance, templates and exception handling. Students will be assessed based on quizzes, assignments, exams and a final exam. Rules require on-time attendance, original work, and no cheating. The reading assignment covers class and object diagrams from a UML book. Assignment 1 is due on September 7th.

Uploaded by

Moiz Ul Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Object Oriented

Programming

Chapter 1

Instructor: Ms. Raazia Sosan

Course Objectives
To make you understand the object oriented programming and advanced C++
concepts
Be able to explain the difference between object oriented programming and procedural
programming.
Be able to program using more advanced C++ features such as composition of objects,
operator overloads, inheritance and polymorphism, etc.
Be able to build C++ classes using appropriate encapsulation and design principles.

Improve your problem solving skills

Be able to apply object oriented or non-object oriented techniques to solve bigger


computing problems

Course Contents
Procedural C++

Abstract classes

Classes

Destruction and Polymorphism

Members

Stream I/O in C++

Procedures versus Objects

Templates

Class Design

Exception Handling

Operator and Method Overloading

Introductory STL

Inheritance

Iterators, containers and algorithms

Virtual Methods

Textbook
Title: Object-Oriented Programming in C++ (4th Edition)
Author(s)/Editor(s): Robert Lafore

Publisher: SAMS
ISBN: 978-0672323089

Reference Material
Title: C++ How to Program
Author(s)/Editor(s): Paul Deital

ISBN: 978-0133378719

Handouts provided by the instructor

Assessment Instruments
Instrument

% of Grade

Quizzes (Best 5)

10%

Assignments (Best 5)

10%

Hourlies exams (3)

30%

Final exam

50%
Total

100%

Rules & Regulations


Maintain discipline in class.
Arrive on time in class. No attendance will be marked after 10 minutes of the start of the
lecture.
Submit your assignment in proper file with a covering sheet containing your name, number,
course title and number of the assignment.
Any completed assignment must be handed to the CR on the due date. After the deadline
zero will be awarded. You must keep a duplicate copy of your work because it may be
needed while the original is being marked.
Coursework, laboratory exercises, reports, and essays submitted for assessment must be your
own work. Zero tolerance towards cheating/plagiarism. Both offenders get F grade. This holds
for sessional exams, assignments, labs and quizzes as well.

Programming Language
Generation
Period

Language

1st
Generation
1944-1959

Machine
Language

2nd
Generation
1959-1965

Assembly
Language

3rd
Generation
1965-1970
High Level
Language
Procedural
Languages

4th
Generation
1970-1980
Much Easier
High Level
Language
Object
Oriented
Language

5th
Generation
Since 1980

Artificial
Intelligence

Procedural Languages
COmmon Business Oriented Language (COBOL) uses terms like file, move and copy.
FORmula TRANslation (FORTRAN) using mathematical language terminology, it was
developed mainly for scientific and engineering problems.

ALGOrithmic Language (ALGOL) focused on being an appropriate language to define


algorithms, while using mathematical language terminology and targeting scientific and
engineering problems just like FORTRAN.
Programming Language One (PL/I) a hybrid commercial/scientific general purpose language
supporting pointers.

Beginners All purpose Symbolic Instruction Code (BASIC) it was developed to enable more
people to write programs.
C a general-purpose programming language, initially developed by Dennis Ritchie between
1969 and 1973 at AT&T Bell Labs.

10

Procedural Languages
Each statement in the language tells the computer to do something
Get some input, add these numbers, divide by six, display that output

A program in a procedural language is a list of instructions


is divided into functions, each function has a clearly defined purpose and a
clearly defined interface to the other functions in the program

grouping a number of functions together into a larger entity called a module

11

Procedural Languages - Issues


programs grow ever larger and more complex - the schedule slips, more
programmers are added, complexity increases, costs skyrocket, the schedule
slips further, and disaster ensues
Unrestricted Access of variables
Real-World Modeling

12

Unrestricted Access of variables

13

Real-World Modeling

Attributes
Color
Horsepower
No.o of door
Behavior
Drive
Brake
Park
Reverse

14

Object Oriented Languages


Simula
Smalltalk

C++
C#
Eiffel

Java

15

Object Oriented Languages


The fundamental idea behind object-oriented languages is to combine into a
single unit both data and the functions that operate on that data. Such a unit is
called an object.

16

OOP: An Approach to
Organization

17

Characteristics of ObjectOriented Languages


Objects
Classes

Inheritance
Reusability
New Data Types

Polymorphism and Overloading

18

Objects
What kinds of things become objects in object-oriented programs? The answer
to this is limited only by your imagination, but here are some typical categories
to start you thinking:
Physical objects
Automobiles in a traffic-flow simulation
Electrical components in a circuit-design program

Countries in an economics model


Aircraft in an air traffic control system

19

Classes
objects are members of classes
ou can declare as many variables of type int as you need, you can define many
objects of the same class
class serves as a plan, or blueprint. It specifies what data and what functions
will be included in objects of that class.
Defining the class doesnt create any objects, just as the mere existence of data
type int doesnt create any variables
An object is often called an instance of a class.

20

Inheritance
In our daily lives, we use the concept of classes divided into subclasses.
We know that the animal class is divided into mammals, amphibians, insects,
birds, and so on. The vehicle class is divided into cars, trucks, buses,
motorcycles, and so on.
The principle in this sort of division is that each subclass shares common
characteristics with the class from which its derived.

the original class is called the base class; other classes can be defined that share
its characteristics, but add their own as well. These are called derived classes.

21

Inheritance contd.

22

Reusability
Once a class has been written, created, and debugged, it can be distributed to
other programmers for use in their own programs. This is called reusability.

It is similar to the way a library of functions in a procedural language can be


incorporated into different programs.

23

New Data Types


One of the benefits of objects is that they give the programmer a convenient
way to construct new data types. Suppose you work with two-dimensional
positions (such as x and y coordinates) in your program. You would like to
express operations on these positional values with normal arithmetic
operations, such as
position1 = position2 + origin
where the variables position1, position2, and origin each represent a pair of
independent numerical quantities. By creating a class that incorporates these
two values, and declaring position1, position2, and origin to be objects of this
class.

24

Polymorphism and Overloading


Note that the = (equal) and + (plus) operators, used in the position arithmetic, dont act the
same way they do in operations on built-in types such as int. The objects position1 and so on
are not predefined in C++, but are programmer-defined objects of class Position.

How do the = and + operators know how to operate on objects? The answer is that we can
define new behaviors for these operators. These operations will be member functions of the
Position class.
Using operators or functions in different ways, depending on what they are operating on, is
called polymorphism (one thing with several distinct forms).

When an existing operator, such as + or =, is given the capability to operate on a new data
type, it is said to be overloaded.
Overloading is a kind of polymorphism; it is also an important feature of OOP.

25

The Unified Modeling Language


(UML)
The UML is a graphical language for modeling computer programs.
Modeling means to create a simplified representation of something, as a
blueprint models a house.
Class diagrams show the relationships among classes, object diagrams show
how specific objects relate, sequence diagrams show the communication
among objects over time, use case diagrams show how a programs users
interact with the program, and so on.

26

Reading Assignment
Read the following chapters from the book Unified Modeling Language User
Guide by Grady Booch

Chapter 8 Class Diagrams

Chapter 14 Object Diagrams

27

Assignment # 1
Due Date: 7th September, 2016

28

Thank You

You might also like