SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
 
C introduction by thooyavan
C introduction by  thooyavanC introduction by  thooyavan
C introduction by thooyavan
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
C programming language
C programming languageC programming language
C programming language
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C basics
C   basicsC   basics
C basics
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
C++ programming
C++ programmingC++ programming
C++ programming
 
c-programming
c-programmingc-programming
c-programming
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
C program
C programC program
C program
 

Similar a Introduction to C++

Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
 
Cs1123 11 pointers
Cs1123 11 pointersCs1123 11 pointers
Cs1123 11 pointers
TAlha MAlik
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
Adeel Hamid
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
marklaloo
 
FILE OPERATIONS.pptx
FILE OPERATIONS.pptxFILE OPERATIONS.pptx
FILE OPERATIONS.pptx
DeepasCSE
 

Similar a 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
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
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
 

Más de Sikder Tahsin Al-Amin

Más 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
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
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
heathfieldcps1
 

Último (20)

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
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
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Ữ Â...
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

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.