SlideShare une entreprise Scribd logo
1  sur  22
INTRODUCTION TO C++
What is OOP 
• Object-oriented programming (OOP) is a 
programming paradigm that represents the 
concept of "objects" that have data fields 
(attributes that describe the object) and 
associated procedures known as methods.
Objects 
• Basic run time entities in OOP. 
• In real world may be a cars, person, bank account etc. 
• Have attributes and behaviors. 
• Cars has colors and speed. 
• In programming, attributes are variables and behaviors 
are functions.
Class 
• A class is a collection of objects of similar type. 
• Mango, Apple etc. are objects and their class is Fruit.
Message Passing 
• Information or message of one object can be sent to other 
object.
Encapsulation 
• Wrapping up of data and functions into a single unit 
(class) is called encapsulation 
• Data is not accessible to outside world. 
• Only those functions which are which are wrapped in the 
class can access it.
Inheritance 
• Inheritance is the process of one class acquire the 
properties of another class.
Polymorphism 
• One name, multiple forms. 
• Allows us to have more than one function with the same 
name in a program.
Why OOP over C 
• Code Reusability (one class code in other) 
• Data is hidden and can’t be accessed by external 
functions. 
• New data and functions can be easily added. 
• Maintenance 
• Software complexity can be reduced. 
• Can be easily upgraded from small to large systems.
Structure of a program 
int main() 
{ 
------------- 
return 0; 
}
A simple C++ program 
• // my first program in C++ 
#include <iostream> 
using namespace std; 
int main() 
{ 
cout << "Hello World!"; 
return 0; 
} 
Hello World
#include <iostream> 
using namespace std; 
int main() 
{ 
cout << "Hello” <<endl << “World!"; 
return 0; 
} 
Hello 
World
Comment 
• C++ supports two ways of commenting code: 
• // line comment 
• /* block comment */
Initialization of variables 
• int a=5; // initial value: 5 
• int b(3); // initial value: 3 
• int c{2}; // initial value: 2
Type deduction: auto and decltype 
• int foo = 0; 
• auto bar = foo; // the same as: int bar = foo; 
• Here, bar is declared as having an auto type; therefore, 
the type of bar is the type of the value used to initialize it: 
in this case it uses the type of foo, which is int.
Type deduction: auto and decltype 
• Variables that are not initialized can also make use of type 
deduction with the decltype specifier: 
• int foo = 0; 
decltype(foo) bar; // the same as: int bar; 
• Here, bar is declared as having the same type as foo.
Reference Variable 
• Provides an alias (alternate name) for a previously 
defined variables. 
• data _type & reference_name = variable_name 
• float total = 100; 
• float & sum = total;
Introduction to strings 
• // my first string 
• #include <iostream> 
• #include <string> 
• using namespace std; 
• int main () 
• { 
• string mystring; 
• mystring = "This is a string"; 
• cout << mystring; 
• return 0; 
• } 
This is a string
Some coding arrangement 
n newline 
r carriage return 
t tab 
v vertical tab 
b backspace 
f form feed (page feed) 
a alert (beep) 
' single quote (') 
" double quote (") 
? question mark (?) 
 backslash ()
Arithmetic Operators 
operator description 
+ addition 
- subtraction 
* multiplication 
/ division 
% modulo
Basic Input/Output 
• // i/o example of taking a number, display and double it 
• #include <iostream> 
• using namespace std; 
• int main () 
• { 
• int i; 
• cout << "Please enter an integer value: "; 
• cin >> i; 
• cout << "The value you entered is " << i; 
• cout << " and its double is " << i*2 << ".n"; 
• return 0; 
• } Please enter an integer value: 702 
The value you entered is 702 and its double is 1404.
Thank you

Contenu connexe

Tendances (20)

C++
C++C++
C++
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C++ programming
C++ programmingC++ programming
C++ programming
 
This pointer
This pointerThis pointer
This pointer
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 

Similaire à Introduction to C++ (20)

Lecture02
Lecture02Lecture02
Lecture02
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
c++ UNIT II.pptx
c++ UNIT II.pptxc++ UNIT II.pptx
c++ UNIT II.pptx
 
Aspdot
AspdotAspdot
Aspdot
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Cs1123 11 pointers
Cs1123 11 pointersCs1123 11 pointers
Cs1123 11 pointers
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
C++ overview
C++ overviewC++ overview
C++ overview
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
02basics
02basics02basics
02basics
 
Lec-1c.pdf
Lec-1c.pdfLec-1c.pdf
Lec-1c.pdf
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
 
FILE OPERATIONS.pptx
FILE OPERATIONS.pptxFILE OPERATIONS.pptx
FILE OPERATIONS.pptx
 
C
CC
C
 
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++
 

Plus de Sikder Tahsin Al-Amin

de Bruijn Graph Construction from Combination of Short and Long Reads
de Bruijn Graph Construction from Combination of Short and Long Readsde Bruijn Graph Construction from Combination of Short and Long Reads
de Bruijn Graph Construction from Combination of Short and Long ReadsSikder Tahsin Al-Amin
 
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...Sikder Tahsin Al-Amin
 
Combinational Logic with MSI and LSI
Combinational Logic with MSI and LSICombinational Logic with MSI and LSI
Combinational Logic with MSI and LSISikder Tahsin Al-Amin
 
Cloud computing for education: A new dawn?
Cloud computing for education: A new dawn?Cloud computing for education: A new dawn?
Cloud computing for education: A new dawn?Sikder Tahsin Al-Amin
 

Plus de Sikder Tahsin Al-Amin (10)

de Bruijn Graph Construction from Combination of Short and Long Reads
de Bruijn Graph Construction from Combination of Short and Long Readsde Bruijn Graph Construction from Combination of Short and Long Reads
de Bruijn Graph Construction from Combination of Short and Long Reads
 
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...
Distance Estimation by Constructing The Virtual Ruler in Anisotropic Sensor N...
 
Graphs - Discrete Math
Graphs - Discrete MathGraphs - Discrete Math
Graphs - Discrete Math
 
Combinational Logic with MSI and LSI
Combinational Logic with MSI and LSICombinational Logic with MSI and LSI
Combinational Logic with MSI and LSI
 
Combinational Logic
Combinational LogicCombinational Logic
Combinational Logic
 
Simplification of Boolean Functions
Simplification of Boolean FunctionsSimplification of Boolean Functions
Simplification of Boolean Functions
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Problem Solving Basics
Problem Solving BasicsProblem Solving Basics
Problem Solving Basics
 
Cloud computing for education: A new dawn?
Cloud computing for education: A new dawn?Cloud computing for education: A new dawn?
Cloud computing for education: A new dawn?
 
Fuzzy clustering of sentence
Fuzzy clustering of sentenceFuzzy clustering of sentence
Fuzzy clustering of sentence
 

Dernier

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 

Dernier (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 

Introduction to C++

  • 2. What is OOP • Object-oriented programming (OOP) is a programming paradigm that represents the concept of "objects" that have data fields (attributes that describe the object) and associated procedures known as methods.
  • 3. Objects • Basic run time entities in OOP. • In real world may be a cars, person, bank account etc. • Have attributes and behaviors. • Cars has colors and speed. • In programming, attributes are variables and behaviors are functions.
  • 4. Class • A class is a collection of objects of similar type. • Mango, Apple etc. are objects and their class is Fruit.
  • 5. Message Passing • Information or message of one object can be sent to other object.
  • 6. Encapsulation • Wrapping up of data and functions into a single unit (class) is called encapsulation • Data is not accessible to outside world. • Only those functions which are which are wrapped in the class can access it.
  • 7. Inheritance • Inheritance is the process of one class acquire the properties of another class.
  • 8. Polymorphism • One name, multiple forms. • Allows us to have more than one function with the same name in a program.
  • 9. Why OOP over C • Code Reusability (one class code in other) • Data is hidden and can’t be accessed by external functions. • New data and functions can be easily added. • Maintenance • Software complexity can be reduced. • Can be easily upgraded from small to large systems.
  • 10. Structure of a program int main() { ------------- return 0; }
  • 11. A simple C++ program • // my first program in C++ #include <iostream> using namespace std; int main() { cout << "Hello World!"; return 0; } Hello World
  • 12. #include <iostream> using namespace std; int main() { cout << "Hello” <<endl << “World!"; return 0; } Hello World
  • 13. Comment • C++ supports two ways of commenting code: • // line comment • /* block comment */
  • 14. Initialization of variables • int a=5; // initial value: 5 • int b(3); // initial value: 3 • int c{2}; // initial value: 2
  • 15. Type deduction: auto and decltype • int foo = 0; • auto bar = foo; // the same as: int bar = foo; • Here, bar is declared as having an auto type; therefore, the type of bar is the type of the value used to initialize it: in this case it uses the type of foo, which is int.
  • 16. Type deduction: auto and decltype • Variables that are not initialized can also make use of type deduction with the decltype specifier: • int foo = 0; decltype(foo) bar; // the same as: int bar; • Here, bar is declared as having the same type as foo.
  • 17. Reference Variable • Provides an alias (alternate name) for a previously defined variables. • data _type & reference_name = variable_name • float total = 100; • float & sum = total;
  • 18. Introduction to strings • // my first string • #include <iostream> • #include <string> • using namespace std; • int main () • { • string mystring; • mystring = "This is a string"; • cout << mystring; • return 0; • } This is a string
  • 19. Some coding arrangement n newline r carriage return t tab v vertical tab b backspace f form feed (page feed) a alert (beep) ' single quote (') " double quote (") ? question mark (?) backslash ()
  • 20. Arithmetic Operators operator description + addition - subtraction * multiplication / division % modulo
  • 21. Basic Input/Output • // i/o example of taking a number, display and double it • #include <iostream> • using namespace std; • int main () • { • int i; • cout << "Please enter an integer value: "; • cin >> i; • cout << "The value you entered is " << i; • cout << " and its double is " << i*2 << ".n"; • return 0; • } Please enter an integer value: 702 The value you entered is 702 and its double is 1404.