seminor_c++
TRANSCRIPT
-
8/9/2019 seminor_C++
1/57
Object Oriented
Programming Language
KGiSL
-
8/9/2019 seminor_C++
2/57
Programming Language
is an artificial language designed to expresscomputations that can be performed by a machine,particularly a computer.
a series of instructions written by a programmer accordingto a given set of rules or conventions (syntax ).
is a notation for writing programs.All P language can be divided into three categories
Problem !riented or "igh evel anguages
#achine !riented or ow evel anguages
#iddle evel anguage
KGiSL
2
-
8/9/2019 seminor_C++
3/57
Programming languages
High-level languages
To speed up programming even further Single statementsfor accomplishing substantial tasks
Translator programs called Compilersto converthigh-level programs into machine language
E.g. add overtime to base pay and store result in gross pay
grossPa ! basePa " overtimePa
KGiSL
3
-
8/9/2019 seminor_C++
4/57
Fortran Algol ! " "## "$
"obol
Eiffel
%avaAda &'()*+ (ascal
$lementary
Procedural
Advanced
Procedural
%tructure !riented
!b&ect
!riented
Advanced
!b&ect
!riented
Ada !3
#pes o$ Programming Language
KGiSL
,
-
8/9/2019 seminor_C++
5/57
%hat is C""&
"## is an obect-oriented programming //(0language that is vie1ed by many as the bestlanguage for creating large-scale applications.
"## is a multi paradigm language.
"## is an obect driven language.
KGiSL
'
-
8/9/2019 seminor_C++
6/57
"## pronounced see plus plus0 1asdeveloped by arne Stroustrup at ell )abs in&4&.
"ombination of Simula4and c" 5ith classes
+n &!36the name 1as changed to "##.
"## is an e7tended version of "."## is a superset of ".
All the concepts of " are applicable to "##also.
'ntroduction to C""
KGiSL
-
8/9/2019 seminor_C++
7/57
(ariables
8ariables are like small blackboards %e can )rite a number on them %e can change the number %e can erase the number
"## variables are names for memorylocations
%e can )rite a value in them %e can change the value stored there %e cannot erase the memor location
Some value is al1ays there
KGiSL
4
-
8/9/2019 seminor_C++
8/57
'denti$iers
Variables names are called identifiersChoosing variable names Use meaningful names that represent data to be
stored
First character must be a letter the underscore character
Remaining characters must be letters
numbers underscore character
KGiSL
!
-
8/9/2019 seminor_C++
9/57
Ke)ords
9ey1ords also called reserved 1ords0 *re used b the C"" language
+ust be used as the are de$ined in the programminglanguage
Cannot be used as identi$iers
Ke)ord is an essential part o$ a language de$inition,
KGiSL
&
-
8/9/2019 seminor_C++
10/57
#pes o$ C Constants
' constants can be divided into two ma&orcategories Primary Constants Secondary Constants
" "onstants
(rimary "onstants Secondary constants
+nteger "onstant:eal "onstant"haracter "onstant
Array6 (ointerStructure6 ;nionenum
KGiSL
C#'O>S
Function is a basic re@uirement of modularprogramming.
The process of dividinga large program into smallsub programs and manipulating them independentlyiskno1n as modular programming.
A function is a named? independent? bloc0 ofstatements that per$orm1ell de$ined? speci$ictas0 and ma return a value.
KGiSL
2
-
8/9/2019 seminor_C++
22/57
Structure o$ =unction
-
8/9/2019 seminor_C++
23/57
'nput and Output
A datastreamis a se@uence of data Typically in the form of characters or numbers
An input stream is data for the program to use Typically originates
at the keyboard
at a file
An output stream is the programs output
?estination is typically the monitor
a file
KGiSL
23
-
8/9/2019 seminor_C++
24/57
Output using cout
coutis an output stream sending data to the monitor-he insertionoperator "
-
8/9/2019 seminor_C++
25/57
'nput 2sing cin
cinis an input streambringing data from the keyboard
The e7tractionoperator BB0gets data to be used
E7ample=cout
-
8/9/2019 seminor_C++
26/57
;eading ata =rom cin
Dultiple data items are separated by spaces?ata is not read until the enter key is
pressed
E7ample=cin >> 1 >> 1 >> 12$
:e@uires three space separated values ;ser might type
3, ,' 2 enter keyB
KGiSL
2
-
8/9/2019 seminor_C++
27/57
esigning 'nput and Output
(rompt the user for input that is desired cout statements provide instructions
cout > age$?isplaying the output 1hat 1as read
cout
-
8/9/2019 seminor_C++
28/57
.asic OOPS Concepts
9>iS)
2!
-
8/9/2019 seminor_C++
29/57
%hat is Object Oriented Programming&
An obect is like ablack bo7.
The internal details
are hidden.
+dentifying objectsandassigning responsibilitiestothese obects.
/bects communicate to otherobects by sending messages.
Dessages are received by themethodsof an obect
KGiSL
2&
-
8/9/2019 seminor_C++
30/57
3>,$
o,@.area(a,)$
,rea8$
case 23couta>>,$
o,@.area(%.=a,)$
,rea8$
case 3e?it(%)$
&
getch()$
&
KGiSL
'