SlideShare a Scribd company logo
1 of 43
Object Oriented
Programming
Lecture 1-2
Aim of the course
 This course provides
 motivation of object oriented programming language
 in depth knowledge of the various concepts of object
oriented programming and its implementation in C++
Course book
 Text book
 C++ How to program by Deitel and Deitel
 Reference books
 Waite Group’s Object oriented programming in C++, Robert
Lafore
 The C++ Programming Language
By Bjarne Stroustrup
 Object-Oriented Software Engineering
By Jacobson, Christerson, Jonsson, Overgaard
Course outline
Classes, Objects, Member functions, Objects as data types,
Constructors and destructors, Overloaded constructor
The default copy constructor, Returning objects from functions,
objects and memory, Static class data, Constant member functions,
Constant objects
Base classes and derived classes, Derived class constructors,
Overloading member functions, Scope resolution, Abstract classes,
Public and private inheritance, Levels of inheritance, Multiple
inheritance, Aggregation and composition
New and delete operators, Pointers to objects, Virtual functions and
late binding, Abstract classes and pure virtual functions, Virtual
destructors, Virtual base classes, Friend functions and friend classes,
Static functions, this pointer, Dynamic type information
Motivation for exception handling, Try-catch block, Throwing an
exception, Catching multiple exceptions
Streams and files, Templates
Marks distribution
 Assignments/Project: 10%
 Quizzes/Project: 10%
 Attendance: 5%
 Mid Term: 25%
 Final Exam: 50%
What is Object-Orientation?
 A technique for system modeling
 OO model consists of several interacting objects
What is a Model?
 A model is an abstraction of something
 Purpose is to understand the product before developing
it
Examples – Model
 Highway maps
 Architectural models
 Mechanical models
What is Object-Orientation?
1– Object Oriented Model
 In the context of programming models are used to
understand the problem before starting developing it.
We make Object Oriented models showing several
interacting objects to understand a system given to us
for implementation.
Object-Orientation -
Advantages
 As Object Oriented Models map directly to reality as we
have seen in examples above therefore, We can easily
develop an object oriented model for a problem.
Everyone can easily understand an object oriented
model. We can easily implement an object oriented
model for a problem using any object oriented language
like c++ using its features1 like classes, inheritance,
virtual functions and so on…
What is an Object?
An object is,
 1. Something tangible (Ali, School, House, Car).
 2. Something conceptual (that can be apprehended
intellectually for example time, date and so on…).
An object has,
 1. State (attributes)
 2. Well-defined behavior (operations)
 3. Unique identity
Tangible and Intangible Objects
Introduction
 Five concepts in object oriented programming are:
 Object
 Classes
 Encapsulation
 Inheritance
 Polymorphism
Simple analogy
 You are driving a car
 You are pressing accelerator pedal
 Someone has design it and built it
 Engineering drawings  car
 Drawings also includes design for accelerator pedal to
make car go faster
 We can say, pedal “hides” complex mechanism that
make the car go faster
Cont.
 Brake pedal “hides” the mechanism that slow the car
 Steering wheel “hides” the mechanism that turn the car
and so on
 Simple “interfaces” like accelerator and brake pedal,
steering wheel, transmission shift and etc. allow driver
to interact car’s complex internal mechanisms
Points to be noted
 You cannot drive the engineering design of a car
 Before you can drive a car, it must be built according to
engineering design
 The car will not accelerator on its own, a driver must
press the accelerator pedal
Object oriented programming
concepts
 Function hides from user the complex task it performs
 Same as accelerator pedal hides complex mechanism of
making the car go faster
 C++ makes a program unit called class that houses
various functions
 Same as car engineering design houses the mechanism
of accelerator pedal
Cont.
 In C++, a class can have various functions that are
design to perform a class tasks
 For example, a class representing bank account might
contain functions
 Deposit money
 Withdraw money
 Current balance
Car example
Real world
 Engineering drawing cannot be
drive
 A car is build from that drawing
 Pressing accelerator pedal sends
a message to car to perform task
(go faster)
C++ programming
• An object of a class
must be created to get
a program to perform
the tasks the class
describes
• Message can be sent to
object by calling a
member functions
Cont.
 Car analogy is used to introduce
 Class
 Objects
 Member functions
 In addition to capabilities of car, it has many attributes
 Color, No. of doors, amount of
gas in tank, total miles driven
and etc
 Attributes are part of car engineering drawing
Cont.
 These attribute are always associated with the car
 Every car maintains its own attribute
 Example 1: each car knows how much gas in its own
tank but do not know how much is in the tanks of other
cars
 Example 2: a bank account object has a balance
attribute. Each bank account object knows the balance
in its account not the others
Object
 Look around right now and you'll find many examples of
real-world objects:
 your dog, your desk, your television set, your bicycle.
 Real-world objects share two characteristics: They all
have
 State and
 Behavior
Object example
 A dog x has state (name, color, breed, hungry) and
behavior (barking, fetching, wagging tail).
 Your bicycle also have state (current gear, current pedal
cadence, current speed) and behavior (changing gear,
changing pedal cadence, applying brakes).
Cont.
 For each object that you see, ask yourself two
questions:
 "What possible states can this object be in?" and
 "What possible behavior can this object perform?"
Real world objects
 Real-world objects vary in complexity
your desktop lamp may have only two
possible states (on and off) and two
possible behaviors (turn on, turn off),
but your desktop radio might have
additional states (on, off, current
volume, current station) and behavior
(turn on, turn off, increase volume,
decrease volume, seek, scan, and
tune).
Cont..
 You may also notice that some objects, in turn, will also
contain other objects.
 These real-world observations all translate into the
world of object-oriented programming
Class
 In the real world, you'll often find many individual
objects all of the same kind
 There may be thousands of other bicycles in existence,
all of the same make and model.
 Each bicycle was built from the same engineering design
and contains the same components.
 In object-oriented terms, we say that your bicycle is
an instance of the class of objects known as bicycles.
Software Object
 Software objects are conceptually similar to real-world
objects: they too consist of state and related behavior.
An object stores its state in
 fields (variables in some programming languages)
and exposes its behavior through
 methods (functions in some programming languages). A
Software Object
Cont.
 Methods operate on an object's internal state and serve
as the primary mechanism for object-to-object
communication.
Class vs. Object
 Class is a blue print of an object, which is non-live
entity.
 Object is instance of class, which is a live entity.
 Example:
 Employee is a class
 Fruit is a class
 I am an object
 apple is an object
Points to remember
 A class is not a living entity, it is just a engineering design that how an
object of this class look like
 Object are living entities
Defining a class with member function
Cont.
 Class definition
 Access specifier – Public
 Class’s body is enclosed in a pair of { }
 Class definition ends at semi colon
 Member function
 Class object
 Dot operator
Member function with parameter
Write a
#include <iostream.h>
#include <string.h>
class book{
private:
char name[25];
int pages;
float price;
public:
void changeName(char *n){
strcpy(name, n);
}
void changePages(int p){
pages = p;
}
void changePrice(float p){
price = p;
}
void display(){
cout<<"name = "<<name<<" pages = "<<pages<<" price = "<<price<<endl;
}
};
Book Class
Simple
program
Class data
 The class book contain three data items
 char name[15];
 int pages;
 float price;
 There can be any number of data members in a class
just as in structure
 There data member lie under keyword private, so they
can be accessed from within the class, but not outside
Member function
 These functions are included in a class
 There are four member functions in class book
 changeName(char *n)
 changePages(int p)
 changePrice(float p)
 display()
 There functions are followed by a keyword public, so they can be accessed
outside the class
Class data and member
function
 Access specifier label public and private
 Function are public and data is private
 Data is hidden so that it can be safe from accidental manipulation
 Functions operates on data are public so they can be accessed from
outside the class
Cont.
 Defining an object is similar to defining a variable of any data type: Space
is set aside for it in memory e.g. int x;
 Defining objects in this way (book b1;) means creating them, also called
instantiating them
 An object is an instance (that is, a specific example) of a class. Objects
are sometimes called instance variables.

More Related Content

Similar to COMP111-Week-1_138439.pptx

Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "AchrafJbr
 
Handout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignHandout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignSAFAD ISMAIL
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1LK394
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
Intro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & ClassesIntro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & ClassesBlue Elephant Consulting
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Blue Elephant Consulting
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideSharebiyu
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesFellowBuddy.com
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Techglyphs
 
Introduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxIntroduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxGauravYadav906294
 

Similar to COMP111-Week-1_138439.pptx (20)

Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
07slide.ppt
07slide.ppt07slide.ppt
07slide.ppt
 
Oo aand d-overview
Oo aand d-overviewOo aand d-overview
Oo aand d-overview
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 
Handout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignHandout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and Design
 
Java getstarted
Java getstartedJava getstarted
Java getstarted
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
Intro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & ClassesIntro to C++ - Class 2 - Objects & Classes
Intro to C++ - Class 2 - Objects & Classes
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++
 
Intro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm ReviewIntro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm Review
 
2 oop
2 oop2 oop
2 oop
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Chapter1 introduction
Chapter1 introductionChapter1 introduction
Chapter1 introduction
 
Introduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxIntroduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptx
 

More from FarooqTariq8

Challenges of Pakistan and foreign policy
Challenges of Pakistan and foreign policy Challenges of Pakistan and foreign policy
Challenges of Pakistan and foreign policy FarooqTariq8
 
01 Habits update (1).pdf
01 Habits update (1).pdf01 Habits update (1).pdf
01 Habits update (1).pdfFarooqTariq8
 
COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxFarooqTariq8
 
Ohms law and its application
Ohms law and its applicationOhms law and its application
Ohms law and its applicationFarooqTariq8
 

More from FarooqTariq8 (7)

Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Challenges of Pakistan and foreign policy
Challenges of Pakistan and foreign policy Challenges of Pakistan and foreign policy
Challenges of Pakistan and foreign policy
 
Ethinic.pdf
Ethinic.pdfEthinic.pdf
Ethinic.pdf
 
01 Habits update (1).pdf
01 Habits update (1).pdf01 Habits update (1).pdf
01 Habits update (1).pdf
 
COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptx
 
Gandhara tahzeeb
Gandhara tahzeebGandhara tahzeeb
Gandhara tahzeeb
 
Ohms law and its application
Ohms law and its applicationOhms law and its application
Ohms law and its application
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

COMP111-Week-1_138439.pptx

  • 2. Aim of the course  This course provides  motivation of object oriented programming language  in depth knowledge of the various concepts of object oriented programming and its implementation in C++
  • 3. Course book  Text book  C++ How to program by Deitel and Deitel  Reference books  Waite Group’s Object oriented programming in C++, Robert Lafore  The C++ Programming Language By Bjarne Stroustrup  Object-Oriented Software Engineering By Jacobson, Christerson, Jonsson, Overgaard
  • 4. Course outline Classes, Objects, Member functions, Objects as data types, Constructors and destructors, Overloaded constructor The default copy constructor, Returning objects from functions, objects and memory, Static class data, Constant member functions, Constant objects Base classes and derived classes, Derived class constructors, Overloading member functions, Scope resolution, Abstract classes, Public and private inheritance, Levels of inheritance, Multiple inheritance, Aggregation and composition New and delete operators, Pointers to objects, Virtual functions and late binding, Abstract classes and pure virtual functions, Virtual destructors, Virtual base classes, Friend functions and friend classes, Static functions, this pointer, Dynamic type information Motivation for exception handling, Try-catch block, Throwing an exception, Catching multiple exceptions Streams and files, Templates
  • 5. Marks distribution  Assignments/Project: 10%  Quizzes/Project: 10%  Attendance: 5%  Mid Term: 25%  Final Exam: 50%
  • 6. What is Object-Orientation?  A technique for system modeling  OO model consists of several interacting objects
  • 7. What is a Model?  A model is an abstraction of something  Purpose is to understand the product before developing it
  • 8. Examples – Model  Highway maps  Architectural models  Mechanical models
  • 10.
  • 11. 1– Object Oriented Model  In the context of programming models are used to understand the problem before starting developing it. We make Object Oriented models showing several interacting objects to understand a system given to us for implementation.
  • 12.
  • 13.
  • 14. Object-Orientation - Advantages  As Object Oriented Models map directly to reality as we have seen in examples above therefore, We can easily develop an object oriented model for a problem. Everyone can easily understand an object oriented model. We can easily implement an object oriented model for a problem using any object oriented language like c++ using its features1 like classes, inheritance, virtual functions and so on…
  • 15. What is an Object? An object is,  1. Something tangible (Ali, School, House, Car).  2. Something conceptual (that can be apprehended intellectually for example time, date and so on…). An object has,  1. State (attributes)  2. Well-defined behavior (operations)  3. Unique identity
  • 17. Introduction  Five concepts in object oriented programming are:  Object  Classes  Encapsulation  Inheritance  Polymorphism
  • 18. Simple analogy  You are driving a car  You are pressing accelerator pedal  Someone has design it and built it  Engineering drawings  car  Drawings also includes design for accelerator pedal to make car go faster  We can say, pedal “hides” complex mechanism that make the car go faster
  • 19. Cont.  Brake pedal “hides” the mechanism that slow the car  Steering wheel “hides” the mechanism that turn the car and so on  Simple “interfaces” like accelerator and brake pedal, steering wheel, transmission shift and etc. allow driver to interact car’s complex internal mechanisms
  • 20. Points to be noted  You cannot drive the engineering design of a car  Before you can drive a car, it must be built according to engineering design  The car will not accelerator on its own, a driver must press the accelerator pedal
  • 21. Object oriented programming concepts  Function hides from user the complex task it performs  Same as accelerator pedal hides complex mechanism of making the car go faster  C++ makes a program unit called class that houses various functions  Same as car engineering design houses the mechanism of accelerator pedal
  • 22. Cont.  In C++, a class can have various functions that are design to perform a class tasks  For example, a class representing bank account might contain functions  Deposit money  Withdraw money  Current balance
  • 23. Car example Real world  Engineering drawing cannot be drive  A car is build from that drawing  Pressing accelerator pedal sends a message to car to perform task (go faster) C++ programming • An object of a class must be created to get a program to perform the tasks the class describes • Message can be sent to object by calling a member functions
  • 24. Cont.  Car analogy is used to introduce  Class  Objects  Member functions  In addition to capabilities of car, it has many attributes  Color, No. of doors, amount of gas in tank, total miles driven and etc  Attributes are part of car engineering drawing
  • 25. Cont.  These attribute are always associated with the car  Every car maintains its own attribute  Example 1: each car knows how much gas in its own tank but do not know how much is in the tanks of other cars  Example 2: a bank account object has a balance attribute. Each bank account object knows the balance in its account not the others
  • 26. Object  Look around right now and you'll find many examples of real-world objects:  your dog, your desk, your television set, your bicycle.  Real-world objects share two characteristics: They all have  State and  Behavior
  • 27. Object example  A dog x has state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail).  Your bicycle also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes).
  • 28. Cont.  For each object that you see, ask yourself two questions:  "What possible states can this object be in?" and  "What possible behavior can this object perform?"
  • 29. Real world objects  Real-world objects vary in complexity your desktop lamp may have only two possible states (on and off) and two possible behaviors (turn on, turn off), but your desktop radio might have additional states (on, off, current volume, current station) and behavior (turn on, turn off, increase volume, decrease volume, seek, scan, and tune).
  • 30. Cont..  You may also notice that some objects, in turn, will also contain other objects.  These real-world observations all translate into the world of object-oriented programming
  • 31. Class  In the real world, you'll often find many individual objects all of the same kind  There may be thousands of other bicycles in existence, all of the same make and model.  Each bicycle was built from the same engineering design and contains the same components.  In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles.
  • 32. Software Object  Software objects are conceptually similar to real-world objects: they too consist of state and related behavior. An object stores its state in  fields (variables in some programming languages) and exposes its behavior through  methods (functions in some programming languages). A Software Object
  • 33. Cont.  Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication.
  • 34. Class vs. Object  Class is a blue print of an object, which is non-live entity.  Object is instance of class, which is a live entity.  Example:  Employee is a class  Fruit is a class  I am an object  apple is an object
  • 35. Points to remember  A class is not a living entity, it is just a engineering design that how an object of this class look like  Object are living entities
  • 36. Defining a class with member function
  • 37. Cont.  Class definition  Access specifier – Public  Class’s body is enclosed in a pair of { }  Class definition ends at semi colon  Member function  Class object  Dot operator
  • 38. Member function with parameter Write a
  • 39. #include <iostream.h> #include <string.h> class book{ private: char name[25]; int pages; float price; public: void changeName(char *n){ strcpy(name, n); } void changePages(int p){ pages = p; } void changePrice(float p){ price = p; } void display(){ cout<<"name = "<<name<<" pages = "<<pages<<" price = "<<price<<endl; } }; Book Class Simple program
  • 40. Class data  The class book contain three data items  char name[15];  int pages;  float price;  There can be any number of data members in a class just as in structure  There data member lie under keyword private, so they can be accessed from within the class, but not outside
  • 41. Member function  These functions are included in a class  There are four member functions in class book  changeName(char *n)  changePages(int p)  changePrice(float p)  display()  There functions are followed by a keyword public, so they can be accessed outside the class
  • 42. Class data and member function  Access specifier label public and private  Function are public and data is private  Data is hidden so that it can be safe from accidental manipulation  Functions operates on data are public so they can be accessed from outside the class
  • 43. Cont.  Defining an object is similar to defining a variable of any data type: Space is set aside for it in memory e.g. int x;  Defining objects in this way (book b1;) means creating them, also called instantiating them  An object is an instance (that is, a specific example) of a class. Objects are sometimes called instance variables.