SlideShare a Scribd company logo
OOP
Lecture-2
Dr. Mohammad Shahidul Islam
Assistant professor
2.1 What is C++
• Its an OOP Language
• Introduced by AT&T bell laboratory in 1980’s
• Still retains the power of C
• Initially it was named as “C with classes”
• C++ is a superset of C
• Some differences will prevent the C to run in
the C++ compiler
DMSI 2
2.1 What is C++
• Important features added over C are classes,
inheritance, function overloading and
operator overloading.
• C++ allows programmers to build large
programs with clarity, extensibility, and ease
of maintenance incorporating the spirit and
efficiency of C
• It facilitates(সহজসাধ্য করে ত ালা) bottom up
approach which was top down in case of C
DMSI 3
Applications of OOP
• OOP language like C++ or JAVA is capable of
handling large programs easily
• Task includes development of editors,
compilers, databases, communication systems
and any complex real time systems
DMSI 4
Applications of OOP
• Since C++ allows us to create hierarchy-related
objects, we can build special object oriented
libraries which can be used later by many
programmers.
• While C++ is able to map the real-world problem
properly, the C part of C++ gives the language the
ability to get close to the machine-level details.
• C++ programs are easily maintainable and
expandable. When a new feature needs to be
implemented, it is vary easy to add to the exiting
structure of an object.
DMSI 5
2.3 A Simple C++ Program
• Printing a string
# include <iostream> // include header file
using namespace std;
Int main()
{
Cout<< “my name is ………..”; //C++ statement
Return 0;
} // end of example
• Program Features
– only one function, main(). //can have more
– Like C the C++ statements terminate with semicolons
DMSI 6
Example (cont.)
• Comments
– C++ introduces a new comment symbol //
– Note that there is no closing symbol
• for*(j=0; j<n; /* loops n times */ J++)
– Can we use double slash?
• Output Operator:
• two ne C++ features, cout and <<.
• The operator << is called the insertion or put to
operator
DMSI 7
Output Operator:
• You may recall that the operator << is the bit-wise left-
shift operator and it can still be used for this purpose.
• This is an example of how one operator can be used for
different purposes, depending on the context.
• This concept is known an operator overloading, an
important aspect of polymorphism.
DMSI 8
The iostream File
• We have used the following #include directive in
the program;
– # include <iostream>
• This directive causes the preprocessor to add the
contents of the iostream file to the program.
• It contains declarations for the identifier cout and
the operator «.
• Some old versions of C++ use a header file called
ioslream.h.
• This is one of the changes introduced by ANSI
C++.
DMSI 9
Return Type of main ( )
• In C++, main() returns an integer type value to the operating
system.
• Therefore, every main() in C + + should end with a return(O)
statement; otherwise a warning or an error might occur.
• Since main() returns an integer type value, return type for main() is
explicitly specified as int. Note that the default return type for all
functions in C++ is int.
• The following main without type and return will run with a warning:
• main()
{
-----
-----
}
DMSI 10
More C+ + Statements
#include<iostream>
using namespace std;
int main()
{
float v1,v2,sum, average;
cout<< "entr the numversn";
cin>> v1;
cin>> v2;
sum=v1+v2;
average=sum/2;
cout<< "sum= "<<sum<<"n";
cout<< "average= "<<average<<"n";
return 0;
}
DMSI 11
• Variables?
• Input Operator?
• Cascading of I/O Operators?
– cout<< "sum= "<<sum<<"n";
– The multiple use of << in one statement is called
cascading
• What is the difference,
cout<< "sum= "<<sum<<“,"
<< "average= "<<average<<"n";
DMSI 12
Class
#include <iostream>
using namespace std;
class person
{
char name[30];
int age;
public:
void getdata(void);
void display(void);
};
void person:: getdata(void)
{
cout<<"enter the namen";
cin>> name;
cout<<"enter the agen";
cin>>age;
}
void person:: display(void)
{
cout<<"Name of the person:
"<<name<<"n";
cout<<"Age of the person:
"<<age<<"n";
}
int main()
{
person p;
p.getdata();
p.display();
return 0;
}
Class (cont.)
• Class person has two two functions called
member function.
• The main program uses person to declare
variables of its type.
• Here P is an object of type person.
Classes in Java:
public class Dog
{
String breed;
int age;
String color;
void barking(){ }
void hungry(){ }
void sleeping(){ }
}
Structure of C++ program
• The previous OOP code shows that a typical
code can have four sections….
– Include files
– Class declaration
– Member functions definition
– Main function program
Client-Server model
• The class definition includinf the member
functions are known as server and
• The main function is know as client
Creating source file
• In C++ we can use text editor to create it
• In UNIX we can use vi or ed editor
• In dos we can use edlin
• The created file should have appropritae
extension to be recognised.
Compiling and Linking
• The process of compiling and linking again
depends upon the operating system.
• Each system has its own command to run.
DMSI 19

More Related Content

What's hot

Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
 
2. data, operators, io
2. data, operators, io2. data, operators, io
2. data, operators, io
Srichandan Sobhanayak
 
C++ Training
C++ TrainingC++ Training
C++ Training
SubhendraBasu5
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
ppd1961
 
Object Oriented Programming With Real-World Scenario
Object Oriented Programming With Real-World ScenarioObject Oriented Programming With Real-World Scenario
Object Oriented Programming With Real-World Scenario
Durgesh Singh
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
Dennis Chang
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
eteaching
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
Haresh Jaiswal
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
C++ OOP Implementation
C++ OOP ImplementationC++ OOP Implementation
C++ OOP ImplementationFridz Felisco
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
Bharat Kalia
 
C# for C++ programmers
C# for C++ programmersC# for C++ programmers
C# for C++ programmersMark Whitaker
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
Nico Ludwig
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 
basics of c++
basics of c++basics of c++
basics of c++
gourav kottawar
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
Sangharsh agarwal
 
Data types in c++
Data types in c++ Data types in c++
Data types in c++
RushikeshGaikwad28
 

What's hot (20)

Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
2. data, operators, io
2. data, operators, io2. data, operators, io
2. data, operators, io
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
Object Oriented Programming With Real-World Scenario
Object Oriented Programming With Real-World ScenarioObject Oriented Programming With Real-World Scenario
Object Oriented Programming With Real-World Scenario
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
C# Basics
C# BasicsC# Basics
C# Basics
 
C++ OOP Implementation
C++ OOP ImplementationC++ OOP Implementation
C++ OOP Implementation
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
C# for C++ programmers
C# for C++ programmersC# for C++ programmers
C# for C++ programmers
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
basics of c++
basics of c++basics of c++
basics of c++
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
Data types in c++
Data types in c++ Data types in c++
Data types in c++
 

Viewers also liked

C++ Programming : Learn OOP in C++
C++ Programming : Learn OOP in C++C++ Programming : Learn OOP in C++
C++ Programming : Learn OOP in C++
richards9696
 
Overview- Skillwise Consulting
Overview- Skillwise Consulting Overview- Skillwise Consulting
Overview- Skillwise Consulting
Skillwise Group
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop InheritanceHadziq Fabroyir
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
Nitin Jawla
 
Pipe & its wall thickness calculation
Pipe & its wall thickness calculationPipe & its wall thickness calculation
Pipe & its wall thickness calculation
sandeepkrish2712
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++Swarup Kumar Boro
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
Steve Johnson
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Valve Selection & Sizing
Valve Selection & SizingValve Selection & Sizing
Valve Selection & Sizing
Ranjeet Kumar
 
Chapter 14 management (10 th edition) by robbins and coulter
Chapter 14 management (10 th edition) by robbins and coulterChapter 14 management (10 th edition) by robbins and coulter
Chapter 14 management (10 th edition) by robbins and coulterMd. Abul Ala
 
01 General Control Valves Training.
01 General Control Valves Training.01 General Control Valves Training.
01 General Control Valves Training.
SuryamshVikrama
 
Valve types and selection
Valve types and selectionValve types and selection
Valve types and selectionMusa Sabri
 
Basic Control Valve Sizing and Selection
Basic Control Valve Sizing and SelectionBasic Control Valve Sizing and Selection
Basic Control Valve Sizing and Selection
ISA Boston Section
 
VALVES AND THEIR TYPES
VALVES AND THEIR TYPESVALVES AND THEIR TYPES
VALVES AND THEIR TYPESMadhur Mahajan
 

Viewers also liked (16)

C++ Programming : Learn OOP in C++
C++ Programming : Learn OOP in C++C++ Programming : Learn OOP in C++
C++ Programming : Learn OOP in C++
 
Overview- Skillwise Consulting
Overview- Skillwise Consulting Overview- Skillwise Consulting
Overview- Skillwise Consulting
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
 
Pipe & its wall thickness calculation
Pipe & its wall thickness calculationPipe & its wall thickness calculation
Pipe & its wall thickness calculation
 
Valve selections
Valve selectionsValve selections
Valve selections
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Valve Selection & Sizing
Valve Selection & SizingValve Selection & Sizing
Valve Selection & Sizing
 
Chapter 14 management (10 th edition) by robbins and coulter
Chapter 14 management (10 th edition) by robbins and coulterChapter 14 management (10 th edition) by robbins and coulter
Chapter 14 management (10 th edition) by robbins and coulter
 
01 General Control Valves Training.
01 General Control Valves Training.01 General Control Valves Training.
01 General Control Valves Training.
 
Valve types and selection
Valve types and selectionValve types and selection
Valve types and selection
 
Control valve ppt
Control valve pptControl valve ppt
Control valve ppt
 
Basic Control Valve Sizing and Selection
Basic Control Valve Sizing and SelectionBasic Control Valve Sizing and Selection
Basic Control Valve Sizing and Selection
 
VALVES AND THEIR TYPES
VALVES AND THEIR TYPESVALVES AND THEIR TYPES
VALVES AND THEIR TYPES
 

Similar to Oop l2

Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
valerie5142000
 
C++ basics
C++ basicsC++ basics
C++ basics
AllsoftSolutions
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
Mohammad Shaker
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
Vaibhav Khanna
 
Presentation c++
Presentation c++Presentation c++
Presentation c++
JosephAlex21
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
cpjcollege
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
PushkarNiroula1
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
Tharindu Weerasinghe
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
LakshyaChauhan21
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
DSCIGDTUW
 
1. Introduction to C++ and brief history
1. Introduction to C++ and brief history1. Introduction to C++ and brief history
1. Introduction to C++ and brief history
Ahmad177077
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
Waqar Younis
 
Parm
ParmParm
Parm
parmsidhu
 
Parm
ParmParm
Parm
parmsidhu
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 

Similar to Oop l2 (20)

Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
C++ basics
C++ basicsC++ basics
C++ basics
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Presentation c++
Presentation c++Presentation c++
Presentation c++
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
 
1. Introduction to C++ and brief history
1. Introduction to C++ and brief history1. Introduction to C++ and brief history
1. Introduction to C++ and brief history
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
Parm
ParmParm
Parm
 
Parm
ParmParm
Parm
 
Chp1(c 2 c++)
Chp1(c 2 c++)Chp1(c 2 c++)
Chp1(c 2 c++)
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 

Recently uploaded

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
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
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
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
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
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
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
 
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
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

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
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
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
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
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
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
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
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

Oop l2

  • 1. OOP Lecture-2 Dr. Mohammad Shahidul Islam Assistant professor
  • 2. 2.1 What is C++ • Its an OOP Language • Introduced by AT&T bell laboratory in 1980’s • Still retains the power of C • Initially it was named as “C with classes” • C++ is a superset of C • Some differences will prevent the C to run in the C++ compiler DMSI 2
  • 3. 2.1 What is C++ • Important features added over C are classes, inheritance, function overloading and operator overloading. • C++ allows programmers to build large programs with clarity, extensibility, and ease of maintenance incorporating the spirit and efficiency of C • It facilitates(সহজসাধ্য করে ত ালা) bottom up approach which was top down in case of C DMSI 3
  • 4. Applications of OOP • OOP language like C++ or JAVA is capable of handling large programs easily • Task includes development of editors, compilers, databases, communication systems and any complex real time systems DMSI 4
  • 5. Applications of OOP • Since C++ allows us to create hierarchy-related objects, we can build special object oriented libraries which can be used later by many programmers. • While C++ is able to map the real-world problem properly, the C part of C++ gives the language the ability to get close to the machine-level details. • C++ programs are easily maintainable and expandable. When a new feature needs to be implemented, it is vary easy to add to the exiting structure of an object. DMSI 5
  • 6. 2.3 A Simple C++ Program • Printing a string # include <iostream> // include header file using namespace std; Int main() { Cout<< “my name is ………..”; //C++ statement Return 0; } // end of example • Program Features – only one function, main(). //can have more – Like C the C++ statements terminate with semicolons DMSI 6
  • 7. Example (cont.) • Comments – C++ introduces a new comment symbol // – Note that there is no closing symbol • for*(j=0; j<n; /* loops n times */ J++) – Can we use double slash? • Output Operator: • two ne C++ features, cout and <<. • The operator << is called the insertion or put to operator DMSI 7
  • 8. Output Operator: • You may recall that the operator << is the bit-wise left- shift operator and it can still be used for this purpose. • This is an example of how one operator can be used for different purposes, depending on the context. • This concept is known an operator overloading, an important aspect of polymorphism. DMSI 8
  • 9. The iostream File • We have used the following #include directive in the program; – # include <iostream> • This directive causes the preprocessor to add the contents of the iostream file to the program. • It contains declarations for the identifier cout and the operator «. • Some old versions of C++ use a header file called ioslream.h. • This is one of the changes introduced by ANSI C++. DMSI 9
  • 10. Return Type of main ( ) • In C++, main() returns an integer type value to the operating system. • Therefore, every main() in C + + should end with a return(O) statement; otherwise a warning or an error might occur. • Since main() returns an integer type value, return type for main() is explicitly specified as int. Note that the default return type for all functions in C++ is int. • The following main without type and return will run with a warning: • main() { ----- ----- } DMSI 10
  • 11. More C+ + Statements #include<iostream> using namespace std; int main() { float v1,v2,sum, average; cout<< "entr the numversn"; cin>> v1; cin>> v2; sum=v1+v2; average=sum/2; cout<< "sum= "<<sum<<"n"; cout<< "average= "<<average<<"n"; return 0; } DMSI 11
  • 12. • Variables? • Input Operator? • Cascading of I/O Operators? – cout<< "sum= "<<sum<<"n"; – The multiple use of << in one statement is called cascading • What is the difference, cout<< "sum= "<<sum<<“," << "average= "<<average<<"n"; DMSI 12
  • 13. Class #include <iostream> using namespace std; class person { char name[30]; int age; public: void getdata(void); void display(void); }; void person:: getdata(void) { cout<<"enter the namen"; cin>> name; cout<<"enter the agen"; cin>>age; } void person:: display(void) { cout<<"Name of the person: "<<name<<"n"; cout<<"Age of the person: "<<age<<"n"; } int main() { person p; p.getdata(); p.display(); return 0; }
  • 14. Class (cont.) • Class person has two two functions called member function. • The main program uses person to declare variables of its type. • Here P is an object of type person.
  • 15. Classes in Java: public class Dog { String breed; int age; String color; void barking(){ } void hungry(){ } void sleeping(){ } }
  • 16. Structure of C++ program • The previous OOP code shows that a typical code can have four sections…. – Include files – Class declaration – Member functions definition – Main function program
  • 17. Client-Server model • The class definition includinf the member functions are known as server and • The main function is know as client
  • 18. Creating source file • In C++ we can use text editor to create it • In UNIX we can use vi or ed editor • In dos we can use edlin • The created file should have appropritae extension to be recognised.
  • 19. Compiling and Linking • The process of compiling and linking again depends upon the operating system. • Each system has its own command to run. DMSI 19