0% found this document useful (0 votes)
21 views30 pages

Lecture 02 17032022 020623pm

Uploaded by

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

Lecture 02 17032022 020623pm

Uploaded by

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

CSC-210: Object Oriented Programming

Introduction to Object Oriented


Programming
Lecture 02

By: Ms. Zupash Awais


Bahria University Lahore Campus
 Assignments 20%
 Quizzes/Class Participation 10%
Marks
 Midterm 20%
Distribution  Final Term 50%
 Revision of Structured Programming
 Introduction of Course
 Class/Objects
 Access Modifiers/Data Members/Member Functions
 Accessor and Mutators
 Constructors
 Const and Static Members
Course Content  Friend Functions
 Operator Overloading
 Polymorphism
 Inheritance
 Association/Composition/Aggregation
 Exception Handling
 Templates
 A computer program is a set of instructions that
instruct the CPU to perform a defined task.
 We can write computer programs using various
programming languages.
Computer  Furthermore, a programming paradigm is a way of
Program categorizing a programming language depending
on its features.
 Two such paradigms are structured and object-
oriented programming.
 Structured Programming
 Structured Programming divides a program into a set of functions
or modules.
 Modular programming is another name for this.
 These functions have statements embraced inside curly braces.
Each of these functions performs a subtask.

Understanding
the difference  Object Oriented Programming
 Object oriented programming allows the programmer to
represent real-world scenarios using objects.
 An object is any entity that has states and behaviors.
 States represent the attributes or data of an object, whereas the
methods represent the behaviors of objects.
 Student, Employee, Book etc. are objects.
 These objects interact with other objects by passing messages.
 Class
 A blueprint for creating an object
 It is necessary to have a class to create objects
Object Oriented
Terms
 Object
 An instance of a Class
Chinese

Language English

Urdu

Spanish Student

Person
Teacher

Employee
Dog

Animal
Cat

Snake
Student

University
Cow
Teacher

Departments

Courses
OO Software
 A technique for system modeling
What is Object-  OO model consists of several objects
Orientation
 A model is an abstraction of something
 Purpose is to understand the Product before
Model developing it.
OO Model
Examples
Object
Example
Example
Write a class named Car that has the following member variables:
• yearModel: An int that holds the car’s year model.
• name: A string that holds the name of the car.
• company: A string that holds the company of the car.
• speed: An int that holds the car’s current speed.

In addition, the class should have the following member functions.

Mutator:

Appropriate accessor functions to set the values of object’s yearModel, name, company,
and speed member variables.

Accessor:

Activity Appropriate accessor functions to get the values stored in an object’s yearModel, make,
and speed member variables.

Accelerate:

The accelerate function should add 5 to the speed member variable each time it is
called.

Brake:

The brake function should subtract 5 from the speed member variable each time it is
called.

You might also like