1
Programming with C++
Lecture 1
Sikander Naseem
2
Program
Standard definition
Set of instructions executed by a computer system
to perform a task (function).
Written in a language referred as computer
languages
3
Computer languages classification
Classified on the level of communication
• Low level: Communication at the native level of computer e.g.
machine language (binary code), Assembly languages.
• High Level: Communication in emulated human like language e.g.
Fortran, Cobol, Pascal, C++
• Intermediate level: Sometime languages such as assembly
languages and C are classified in intermediate level.
4
Comparison
Low level High Level
• Efficient in execution Opposite
• Difficult to read/write
• Cross Device(hardware)
implementation restrictions
5
Object oriented programing
Object Technology
• Object: Anything with which we can interact through
human sense (Grammar reference)
• The technology was first used in Simula programing
language in 1960s, developed in Norway
• In Simula Physical objects e.g. a Door is modeled as object
which can be accessed by another object e.g. a Person
6
Object oriented programing
Standard Programming structure: Sets of instructions
with operations and data are separate aspects
In context of Object Technology: Operations and Data
are two portions of a single object.
We can establish that the in object oriented program
we have collection of well designed objects
interacting with each other to perform a specific task
(function).
7
Object oriented programing
Mechanical system example with objects: Bodies with
mass, Physical quantities (work, force heat)
DATA DATA
Object 1 Object 2
Operations Operations
Program in context of object technology
8
Object oriented programing
Operation: Ears
• the available methods for an object. Eyes
Also referred as the functions of the
object. Mouth
• Means of interaction with other
objects Legs
Data:
• Item or variables defining the Fig: Cow Object and its attributes
attributes (properties) of the object
Instructions: Operations: Running, eating, hearing
• To pass the message to perform
certain the operations
9
Object oriented programing
For a Programmer Object is a black box for which
• Data is given
• Enabling it to lists its methods (operations)
• Messaging between the objects ( e.g. instructing a pet to run)
10
Object oriented programing
Objects for Programmer
DATA DATA DATA
Object X
Operations Operations
Operations Operations
Object Y
DATA DATA DATA
11
Object Classes
Generally objects are grouped in Generic Classes
For instance, object triangle, circle, square can be
grouped together in class “Diagram”
And objects Shan, Aziz can be grouped together in
class “Person”
12
Object Classes
Class templates: Contains basic data of an objects
related to that class.
For e.g. data types objects such as int “i”, string
“s”
Class Object
Person Shan
Diagram triangle
Int i
String s
13
Key Object Orientation concepts
DIYS from Chapter 2
• Abstraction
• Encapsulation
• Aggregation/composition
• Inheritance
14
The End
Thanks for coming
Reference books:
Turbo C++ by examples, Greg Perry and Marcus Johnson,
1st Edition, Prentice Hall, Holis NH
Programming with C++, SCHAUM’s outlines, John Hubbard,
3rd Edition, McGraw Hill, New Delhi