SlideShare a Scribd company logo
Lecture 1
Introduction
Thinking in Objects
• You can walk into a computer store and, with a
little background and often some help, assemble
an entire PC from various components: a
motherboard, a CPU chip, a video card, a hard
disk, a keyboard, and so on.
• Ideally, when you finish assembling all the various
self-contained units, you have a system in which
all the units work together to create a larger
system with which you can solve the problems
you bought the computer for in the first place.
• Internally, each of those components may be
vastly complicated and engineered by
different companies with different methods of
design. But you don't need to know how the
component works, what every chip on the
board does, or how, when you press the ‘A’
key, an ‘A’ gets sent to your computer. As the
assembler of the overall system, each
component you use is a self-contained unit,
and all you are interested in is how the units
interact with each other.
• Will this video card fit into the slots on the
motherboard, and will this monitor work with
this video card?
• Will each particular component speak the right
commands to the other components it interacts
with so that each part of the computer is
understood by every other part?
• Once you know what the interactions are
between the components and can match the
interactions, putting together the overall system
is easy.
What does this have to do with
programming?
Everything.
Object-oriented programming works in exactly
this same way. Using object-oriented
programming, your overall program is made
up of lots of different self-contained
components (objects), each of which has a
specific role in the program and all of which
can talk to each other in predefined ways.
Problem Statement
Dominos made orders on behalf of registered
customer. An order consists of a number of
items. The order is either pending or serviced.
The following are the set of requirements
regarding placed and serviced orders:
1. An order may be placed by registered
customer.
2. A single customer may place a number of
orders.
3. An order may be deleted or edited before
being serviced.
4. An order must include at least one item (No
null order).
5. The desired quantity of an placed item must
not be null.
6. An order is serviced only after receiving
payment from a customer.
7. The customer can pay by cash or by card.
8. An invoice is made at the time of servicing the
order.
Contents
• Basic Concepts of C++
• Difference between C and C++
• Applications of C++
• How a program is Compiled?
• Simple C++ Program
Basic Concepts of C++
Basic Concepts of C++
Layers of Computer Software
Basic Concepts of C++
• Object Oriented Programming is method of programming where a system is
considered as a collection of objects that interact together to accomplish certain
tasks. Objects are entities that encapsulate data and procedures that operate on
the data.
• In OOPS first a concept known as "Object Oriented Analysis (OOA)" is used
to specify the objects in term of real world requirements, their behavior and
interactions required. The next concept would be the "Object Oriented Design
(OOD)" that converts these real-time requirements as a hierarchy of objects in
terms of software development requirement. Finally OOPS is used to
implement the requirements using the C++ programming language.
• The main purpose of object oriented programming is to simplify the design,
programming and most importantly debugging a program. So to modify a
particular data, it is easy to identify which function to use. To add additional
features it is easy to identify where to add functions and its related data.
Basic Concepts of C++
Basic Concepts of C++
• Object Oriented Programming Language
• Basic Concepts:
• Objects
• Classes
• Data Abstraction
• Encapsulation
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing
• Basic runtime entity in an object – oriented system.
• Often termed as “instance” of a class.
• Example:
– a person, a place, a bank account etc.
• They can be of any type based on its declaration.
• When program is executed, objects interact by sending messages
at runtime.
• Example 2:
– Two objects namely, “customer”, “account”. Customer object
may send a message to the account object requesting for bank
balance.
Objects
• Class is a collection of objects of similar type.
• Class is a way to bind the data and its associated functions
together.
• Objects are basically variable of the class or an object is an
instance of a class.
• Examples:
– Shape is a class and Rectangle, Square, Triangle are its objects.
–
Classes
Abstraction
• Providing only essential information to the outside world i.e. to
represent the needed information in program without presenting the
details.
• Data abstraction is a programming/ design technique that relies on
the separation of interface and implementation.
• In C++, they provide sufficient public methods to the outside world
to play with the functionality of the object and to manipulate object
data, i.e., state without actually knowing how class has been
implemented internally.
• Eg: While using an object (that is an instance of a class) the
built in data types and the members in the class are ignored.
This is known as data abstraction.
Abstraction
Encapsulation
• All C++ programs are composed of the following two
fundamental elements:
– Program statements (code): This is the part of a program that
performs actions and they are called functions.
– Program data: The data is the information of the program which
affected by the program functions.
• Encapsulation is an Object Oriented Programming concept that
binds together the data and functions that manipulate the data,
and that keeps both safe from outside interference and misuse.
• Data encapsulation led to the important OOP concept of data
hiding.
Encapsulation
• C++ supports the properties of encapsulation and data hiding
through the creation of user-defined types, called classes.
• Eg: a class can contain
– private, protected, public members.
Inheritance
• Inheritance works on the basis of re-usability.
• This provides us an opportunity to reuse the code functionality
and fast implementation time.
• When creating a class, instead of writing completely new data
members and member functions, the programmer can designate
that the new class should inherit the members of an existing
class. This existing class is called the base class, and the new
class is referred to as the derived class.
• The idea of inheritance implements the is a relationship.
Inheritance
Polymorphism
• Poly means many and morphism means changing or alterable.
• The word polymorphism means having many forms.
Polymorphism
• C++ polymorphism means that a call to a member function will
cause a different function to be executed depending on the type
of object that invokes the function.
Dynamic Binding
• Binding refers to the linking of a procedure call to the
code to be executed in response to the call.
• Dynamic binding (late binding) means that the code
associated with a given procedure call is not known
until the time of the call at run-time.
• Associated with polymorphism and inheritance.
Message Passing
• OOPs consists of a set of objects that communicate with each
other.
• This involves following steps:
– Creating classes that define objects and their behavior
– Creating objects from class definitions.
– Establishing communication among objects
• A message for an object is a request for execution of a
procedure, and therefore will invoke a function (procedure)
in the receiving object that generates the desired result.
Message Passing
• Message passing involves specifying the name of the object,
the name of the function (message) and the information to be
sent.
Difference between C and C++
Difference between C and C++
S. No. Procedural Programming (C) Object Oriented Programming (C++)
1 Emphasis is on doing things
(algorithms).
Emphasis is on data rather than
procedure.
2 Large programs are divided
into smaller programs in the
form of functions.
Programs are divided into objects.
Functions that operate together are
tied together in the data structure.
3 Most of the functions share
global data.
Data is mostly hidden and cannot be
accessed by external functions.
4 Data move openly around the
system from function to
function. Functions transform
data from one form to another.
Objects may communicate with each
other through functions. New data
and functions can be easily added
wherever necessary.
5 Employs top-down approach in
program design.
Follow bottom-up approach in
program design.
Difference between C and C++
Functioning of Procedural Language Functioning of Object Oriented
Programming Language
• A class is an extension of the idea of structure used in
C.
• A new way of creating and implementing user-
defined data type.
Difference between C and C++
C Structures
• Provide a method for packing together data of different types.
• A convenient tool for handling a group of logically related data
items.
• Eg:
struct student
{
char name[20];
int roll_no;
float total_marks;
} A;
Limitations
• Cannot treat struct data-type like built in data type.
Example:
struct Complex
{
float x;
float y;
} c1, c2,c3;
Complex nos. c1, c2, c3 can be easily assigned values using dot
operator, but we can’t directly add or subtract two complex nos.
i.e.
c3 = c1 + c2; // illegal in C.
• Do not permit data hiding. Structure members are public
members.
C++ Classes
• Attempts to bring user defined types as close as
possible to the built-in data types.
• Also provides facility to hide the data.
• Inheritance is also supported by C++
Applications
Applications of OOPs Languages
• Real-time systems
• Simulation and Modeling
• Object-oriented Databases
• Hypertext and Hypermedia systems
• AI and expert systems
• Neural Networks and parallel programming
• Decision Support and office automation systems
• CIM/CAM/CAD systems
How a Program is Executed?
Flowchart
• C++ program is written in an Editor.
• Saved as a file with extension .cpp.
1. Editor
• Preprocessing performs (usually simple) operations on the
source file(s) prior to compilation.
• Typical preprocessing operations include:
(a) Expanding macros (shorthand notations for longer
constructs). For example, in C,
#define abc(x,y) (3*x+y*(2+x))
In program n = abc(a,b) becomes
n = (3*a+b*(2+a))
• (b) Inserting named files. For example, in C++,
# include <iostream>
is replaced by the contents of the file iostream.h
2. Preprocessor
• Compiler is a program that can read a program in one
language — the source language — and translate it into
an equivalent program in another language — the target
language or machine language.
• An important role of the compiler is to report any errors
in the source program that it detects during the
translation process.
3. Compiler
• A linker combines object code (machine code that
has not yet been linked) produced from compiling
and assembling many source programs, as well as
standard library functions and resources supplied by
the operating system.
4. Linker
• Compilers, assemblers and linkers usually produce code whose
memory references are made relative to an undetermined
starting location that can be anywhere in memory.
(relocatable machine code)
• The loader then puts together all of the executable object files
into memory for execution.
• A loader calculates appropriate absolute addresses for these
memory locations and amends the code to use these addresses.
5. Loader
6. Execute
CPU executes the program one instruction at time.
A Bit more about execution
1. To stop the process
after the preprocessor
step, you can use the -
E option:
g++ -E prog1.cpp
The expanded source
code file will be printed
on standard output (the
screen by default).
2. To stop the process after
the compile step, you can
use the -S option:
g++ -S prog1.cpp
By default, the assembler
code for a source file
named filename.cpp will
be placed in a file
named filename.s.
3. To stop the process after
the assembly step, you
can use -c option:
g++ -c prog1.cpp
By default, the assembler
code for a source file
named filename.cpp will
be placed in a file
named filename.o.
A simple C++ Program
General Structure of C++ Program
“Hello World” in C++
using namespace std;
#include <iostream>
// My first C++ program!
int main(void)
{
cout << "hello world!" << endl;
return 0;
}
Use the standard namespace
Include standard
iostream classes
A C++ comment
cout is an
instance of
iostream
operator overloading
(two different argument types!)
Thank You

More Related Content

Similar to Lecture 1.pptx

SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
nikshaikh786
 
C++ & VISUAL C++
C++ & VISUAL C++ C++ & VISUAL C++
C++ & VISUAL C++
Makaha Rutendo
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdf
Ann Wera
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
LakshyaChauhan21
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
Rokonuzzaman Rony
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
shammi mehra
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
shashiden1
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
Rai University
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
Rai University
 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - Revision
Michael Heron
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
sagarjsicg
 
C++ chapter 1
C++ chapter 1C++ chapter 1
C++ chapter 1
jasvinder162
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
YashKoli22
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-i
Taymoor Nazmy
 
[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP
Muhammad Hammad Waseem
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
umesh patil
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
floraaluoch3
 
Object oriented programming
Object oriented programmingObject oriented programming
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 

Similar to Lecture 1.pptx (20)

SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
C++ & VISUAL C++
C++ & VISUAL C++ C++ & VISUAL C++
C++ & VISUAL C++
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdf
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - Revision
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
 
C++ chapter 1
C++ chapter 1C++ chapter 1
C++ chapter 1
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-i
 
[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP[OOP - Lec 02] Why do we need OOP
[OOP - Lec 02] Why do we need OOP
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
 
DOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in cDOC-20210303-WA0017..pptx,coding stuff in c
DOC-20210303-WA0017..pptx,coding stuff in c
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

Lecture 1.pptx

  • 2. Thinking in Objects • You can walk into a computer store and, with a little background and often some help, assemble an entire PC from various components: a motherboard, a CPU chip, a video card, a hard disk, a keyboard, and so on. • Ideally, when you finish assembling all the various self-contained units, you have a system in which all the units work together to create a larger system with which you can solve the problems you bought the computer for in the first place.
  • 3. • Internally, each of those components may be vastly complicated and engineered by different companies with different methods of design. But you don't need to know how the component works, what every chip on the board does, or how, when you press the ‘A’ key, an ‘A’ gets sent to your computer. As the assembler of the overall system, each component you use is a self-contained unit, and all you are interested in is how the units interact with each other.
  • 4. • Will this video card fit into the slots on the motherboard, and will this monitor work with this video card? • Will each particular component speak the right commands to the other components it interacts with so that each part of the computer is understood by every other part? • Once you know what the interactions are between the components and can match the interactions, putting together the overall system is easy.
  • 5. What does this have to do with programming? Everything. Object-oriented programming works in exactly this same way. Using object-oriented programming, your overall program is made up of lots of different self-contained components (objects), each of which has a specific role in the program and all of which can talk to each other in predefined ways.
  • 6. Problem Statement Dominos made orders on behalf of registered customer. An order consists of a number of items. The order is either pending or serviced. The following are the set of requirements regarding placed and serviced orders: 1. An order may be placed by registered customer. 2. A single customer may place a number of orders.
  • 7. 3. An order may be deleted or edited before being serviced. 4. An order must include at least one item (No null order). 5. The desired quantity of an placed item must not be null. 6. An order is serviced only after receiving payment from a customer. 7. The customer can pay by cash or by card. 8. An invoice is made at the time of servicing the order.
  • 8. Contents • Basic Concepts of C++ • Difference between C and C++ • Applications of C++ • How a program is Compiled? • Simple C++ Program
  • 10. Basic Concepts of C++ Layers of Computer Software
  • 12. • Object Oriented Programming is method of programming where a system is considered as a collection of objects that interact together to accomplish certain tasks. Objects are entities that encapsulate data and procedures that operate on the data. • In OOPS first a concept known as "Object Oriented Analysis (OOA)" is used to specify the objects in term of real world requirements, their behavior and interactions required. The next concept would be the "Object Oriented Design (OOD)" that converts these real-time requirements as a hierarchy of objects in terms of software development requirement. Finally OOPS is used to implement the requirements using the C++ programming language. • The main purpose of object oriented programming is to simplify the design, programming and most importantly debugging a program. So to modify a particular data, it is easy to identify which function to use. To add additional features it is easy to identify where to add functions and its related data. Basic Concepts of C++
  • 13. Basic Concepts of C++ • Object Oriented Programming Language • Basic Concepts: • Objects • Classes • Data Abstraction • Encapsulation • Inheritance • Polymorphism • Dynamic Binding • Message Passing
  • 14. • Basic runtime entity in an object – oriented system. • Often termed as “instance” of a class. • Example: – a person, a place, a bank account etc. • They can be of any type based on its declaration. • When program is executed, objects interact by sending messages at runtime. • Example 2: – Two objects namely, “customer”, “account”. Customer object may send a message to the account object requesting for bank balance. Objects
  • 15. • Class is a collection of objects of similar type. • Class is a way to bind the data and its associated functions together. • Objects are basically variable of the class or an object is an instance of a class. • Examples: – Shape is a class and Rectangle, Square, Triangle are its objects. – Classes
  • 16. Abstraction • Providing only essential information to the outside world i.e. to represent the needed information in program without presenting the details. • Data abstraction is a programming/ design technique that relies on the separation of interface and implementation. • In C++, they provide sufficient public methods to the outside world to play with the functionality of the object and to manipulate object data, i.e., state without actually knowing how class has been implemented internally. • Eg: While using an object (that is an instance of a class) the built in data types and the members in the class are ignored. This is known as data abstraction.
  • 18. Encapsulation • All C++ programs are composed of the following two fundamental elements: – Program statements (code): This is the part of a program that performs actions and they are called functions. – Program data: The data is the information of the program which affected by the program functions. • Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. • Data encapsulation led to the important OOP concept of data hiding.
  • 19. Encapsulation • C++ supports the properties of encapsulation and data hiding through the creation of user-defined types, called classes. • Eg: a class can contain – private, protected, public members.
  • 20. Inheritance • Inheritance works on the basis of re-usability. • This provides us an opportunity to reuse the code functionality and fast implementation time. • When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class. • The idea of inheritance implements the is a relationship.
  • 22. Polymorphism • Poly means many and morphism means changing or alterable. • The word polymorphism means having many forms.
  • 23. Polymorphism • C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
  • 24. Dynamic Binding • Binding refers to the linking of a procedure call to the code to be executed in response to the call. • Dynamic binding (late binding) means that the code associated with a given procedure call is not known until the time of the call at run-time. • Associated with polymorphism and inheritance.
  • 25. Message Passing • OOPs consists of a set of objects that communicate with each other. • This involves following steps: – Creating classes that define objects and their behavior – Creating objects from class definitions. – Establishing communication among objects • A message for an object is a request for execution of a procedure, and therefore will invoke a function (procedure) in the receiving object that generates the desired result.
  • 26. Message Passing • Message passing involves specifying the name of the object, the name of the function (message) and the information to be sent.
  • 28. Difference between C and C++ S. No. Procedural Programming (C) Object Oriented Programming (C++) 1 Emphasis is on doing things (algorithms). Emphasis is on data rather than procedure. 2 Large programs are divided into smaller programs in the form of functions. Programs are divided into objects. Functions that operate together are tied together in the data structure. 3 Most of the functions share global data. Data is mostly hidden and cannot be accessed by external functions. 4 Data move openly around the system from function to function. Functions transform data from one form to another. Objects may communicate with each other through functions. New data and functions can be easily added wherever necessary. 5 Employs top-down approach in program design. Follow bottom-up approach in program design.
  • 29. Difference between C and C++ Functioning of Procedural Language Functioning of Object Oriented Programming Language
  • 30. • A class is an extension of the idea of structure used in C. • A new way of creating and implementing user- defined data type. Difference between C and C++
  • 31. C Structures • Provide a method for packing together data of different types. • A convenient tool for handling a group of logically related data items. • Eg: struct student { char name[20]; int roll_no; float total_marks; } A;
  • 32. Limitations • Cannot treat struct data-type like built in data type. Example: struct Complex { float x; float y; } c1, c2,c3; Complex nos. c1, c2, c3 can be easily assigned values using dot operator, but we can’t directly add or subtract two complex nos. i.e. c3 = c1 + c2; // illegal in C. • Do not permit data hiding. Structure members are public members.
  • 33. C++ Classes • Attempts to bring user defined types as close as possible to the built-in data types. • Also provides facility to hide the data. • Inheritance is also supported by C++
  • 35. Applications of OOPs Languages • Real-time systems • Simulation and Modeling • Object-oriented Databases • Hypertext and Hypermedia systems • AI and expert systems • Neural Networks and parallel programming • Decision Support and office automation systems • CIM/CAM/CAD systems
  • 36. How a Program is Executed?
  • 38. • C++ program is written in an Editor. • Saved as a file with extension .cpp. 1. Editor
  • 39. • Preprocessing performs (usually simple) operations on the source file(s) prior to compilation. • Typical preprocessing operations include: (a) Expanding macros (shorthand notations for longer constructs). For example, in C, #define abc(x,y) (3*x+y*(2+x)) In program n = abc(a,b) becomes n = (3*a+b*(2+a)) • (b) Inserting named files. For example, in C++, # include <iostream> is replaced by the contents of the file iostream.h 2. Preprocessor
  • 40. • Compiler is a program that can read a program in one language — the source language — and translate it into an equivalent program in another language — the target language or machine language. • An important role of the compiler is to report any errors in the source program that it detects during the translation process. 3. Compiler
  • 41. • A linker combines object code (machine code that has not yet been linked) produced from compiling and assembling many source programs, as well as standard library functions and resources supplied by the operating system. 4. Linker
  • 42. • Compilers, assemblers and linkers usually produce code whose memory references are made relative to an undetermined starting location that can be anywhere in memory. (relocatable machine code) • The loader then puts together all of the executable object files into memory for execution. • A loader calculates appropriate absolute addresses for these memory locations and amends the code to use these addresses. 5. Loader
  • 43. 6. Execute CPU executes the program one instruction at time.
  • 44. A Bit more about execution 1. To stop the process after the preprocessor step, you can use the - E option: g++ -E prog1.cpp The expanded source code file will be printed on standard output (the screen by default).
  • 45. 2. To stop the process after the compile step, you can use the -S option: g++ -S prog1.cpp By default, the assembler code for a source file named filename.cpp will be placed in a file named filename.s.
  • 46. 3. To stop the process after the assembly step, you can use -c option: g++ -c prog1.cpp By default, the assembler code for a source file named filename.cpp will be placed in a file named filename.o.
  • 47. A simple C++ Program
  • 48. General Structure of C++ Program
  • 49. “Hello World” in C++ using namespace std; #include <iostream> // My first C++ program! int main(void) { cout << "hello world!" << endl; return 0; } Use the standard namespace Include standard iostream classes A C++ comment cout is an instance of iostream operator overloading (two different argument types!)