Chapter 1 PDF
Chapter 1 PDF
Programming
Chapter 1
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.
Course Contents
Procedural C++
Abstract classes
Classes
Members
Templates
Class Design
Exception Handling
Introductory STL
Inheritance
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
Assessment Instruments
Instrument
% of Grade
Quizzes (Best 5)
10%
Assignments (Best 5)
10%
30%
Final exam
50%
Total
100%
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.
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
11
12
13
Real-World Modeling
Attributes
Color
Horsepower
No.o of door
Behavior
Drive
Brake
Park
Reverse
14
C++
C#
Eiffel
Java
15
16
OOP: An Approach to
Organization
17
Inheritance
Reusability
New Data Types
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
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.
23
24
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
26
Reading Assignment
Read the following chapters from the book Unified Modeling Language User
Guide by Grady Booch
27
Assignment # 1
Due Date: 7th September, 2016
28
Thank You