SlideShare a Scribd company logo
Introduction ttoo PPrrooggrraammmmiinngg 
LLeeccttuurree 2299
PPrriivvaattee 
PPuubblliicc
EEnnccaappssuullaattiioonn 
Data Hiding
FFrriieenndd 
Friend Function
FFrriieenndd 
FFuunnccttiioonn ccllaassss DDaattee 
{{ 
---- 
ffrriieenndd ffuunnccttiioonnNNaammee (( AArrgguummeenntt__lliisstt )) ;; 
---- 
}} ;;
FFrriieenndd 
FFuunnccttiioonn  FFrriieenndd ffuunnccttiioonnss aarree NNOOTT tthhee mmeemmbbeerrss ooff 
tthhee ccllaassss 
 TThhee ccllaassss iittsseellff ddeeccllaarree iitt’’ss ffrriieenndd 
ffuunnccttiioonnss 
 TThhee pprroottoottyyppee ooff tthheessee ffuunnccttiioonnss aarree 
wwrriitttteenn iinnssiiddee tthhee ccllaassss aanndd tthhee kkeeyy wwoorrdd 
ffrriieenndd iiss aappppeennddeedd bbeeffoorree tthhee ffuunnccttiioonn 
nnaammee 
 FFrriieenndd ffuunnccttiioonnss hhaavvee aacccceessss ttoo pprriivvaattee 
aanndd ppuubblliicc mmeemmbbeerrss ooff tthhee ccllaassss
EExxaammppllee 11 
ccllaassss mmyyCCllaassss 
{{ 
ffrriieenndd iinnccrreemmeenntt (( mmyyCCllaassss ,, iinntt )) ;; 
pprriivvaattee:: 
iinntt ttooppSSeeccrreett ;; 
ppuubblliicc:: 
mmyyCCllaassss (( )) 
{{ ttooppSSeeccrreett == 110000 ;; }} 
vvooiidd DDiissppllaayy (( )) 
{{ ccoouutt<<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iiss ““ 
<<<< ttooppSSeeccrreett ;; }} 
}} ;;
EExxaammppllee 11 
vvooiidd IInnccrreemmeenntt (( mmyyCCllaassss AA ,, iinntt ii )) 
{{ 
AA..ttooppSSeeccrreett ++== ii ;; 
}}
EExxaammppllee 11 
mmaaiinn (( )) 
{{ 
mmyyCCllaassss xx ;; 
xx..DDiissppllaayy (( )) ;; 
IInnccrreemmeenntt (( xx ,, 1100 )) ;; 
xx..DDiissppllaayy (( )) ;; 
}}
EExxaammppllee 11:: OOuuttppuutt 
TThhee vvaalluuee ooff ttooppSSeeccrreett iiss 110000 
TThhee vvaalluuee ooff ttooppSSeeccrreett iiss 111100
EExxaammppllee 22 
ccllaassss mmyyCCllaassssTTwwoo ;; 
ccllaassss mmyyCCllaassssOOnnee 
{{ 
pprriivvaattee :: 
iinntt ttooppSSeeccrreett ;; 
ppuubblliicc :: 
vvooiidd DDiissppllaayy (( )) ;; 
mmyyCCllaassssOOnnee (( )) 
{{ ttooppSSeeccrreett == 110000;; }} 
ffrriieenndd AAddddBBootthh (( mmyyCCllaassssOOnnee ,, mmyyCCllaassssTTwwoo )) ;; 
}} ;;
EExxaammppllee 22 
ccllaassss mmyyCCllaassssTTwwoo 
{{ 
pprriivvaattee:: 
iinntt ttooppSSeeccrreett ;; 
ppuubblliicc:: 
vvooiidd DDiissppllaayy (( )) ;; 
mmyyCCllaassssTTwwoo (( )) 
{{ ttooppSSeeccrreett == 220000 ;; }} 
ffrriieenndd AAddddBBootthh (( mmyyCCllaassssOOnnee ,, mmyyCCllaassssTTwwoo )) ;; 
}} ;;
EExxaammppllee 22 
mmaaiinn (( )) 
{{ 
mmyyCCllaassssOOnnee AA ;; 
mmyyCCllaassssTTwwoo BB ;; 
AA..DDiissppllaayy (( )) ;; 
BB..DDiissppllaayy (( )) ;; 
AAddddBBootthh (( AA ,, BB )) ;; 
}}
EExxaammppllee 22 
iinntt AAddddBBootthh (( mmyyCCllaassssOOnnee AA ,, mmyyCCllaassssTTwwoo BB )) 
{{ 
ccoouutt <<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iinn mmyyCCllaassssOOnnee oobbjjeecctt 
iiss”” <<<< AA..ttooppSSeeccrreett ;; 
ccoouutt <<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iinn mmyyCCllaassssTTwwoo oobbjjeecctt 
iiss””<<<< BB..ttooppSSeeccrreett ;; 
ccoouutt <<<< ““TThhee ssuumm ooff ttooppSSeeccrreett vvaalluueess iinn ““ 
<<<< ““mmyyCCllaassssOOnnee aanndd mmyyCCllaassssTTwwoo oobbjjeecctt iiss ”” 
<<<< AA..ttooppSSeeccrreett ++ BB..ttooppSSeeccrreett ;; 
}}
EExxaammppllee 33 
ccllaassss ootthheerrCCllaassss ;; 
ccllaassss ccllaassssOOnnee 
{{ 
pprriivvaattee :: 
iinntt ttooppSSeeccrreett;; 
ppuubblliicc :: 
vvooiidd DDiissppllaayy (( )) ;; 
ccllaassssOOnnee (( )) 
{{ TTooppSSeeccrreett == 110000 ;; }} 
ffrriieenndd ootthheerrCCllaassss ;; 
}} ;;
SSttrraaiigghhtt LLiinnee 
yy == mmxx ++ cc 
Slope Intercept 
on y axis
SSttrraaiigghhtt LLiinnee 
ccllaassss ssttrraaiigghhttLLiinnee 
{{ 
ddoouubbllee ssllooppee ,, iinntteerrcceepptt ;; 
//// mmeemmbbeerr ffuunnccttiioonn 
}} ;;
QQuuaaddrraattiicc 
yy == aaxx22 ++bbxx ++ cc
QQuuaaddrraattiicc 
ccllaassss qquuaaddrraattiicc 
{{ 
pprriivvaattee :: 
ddoouubbllee aa ,, bb ,, cc ;; 
//// mmeemmbbeerr ffuunnccttiioonn 
}} ;;
LLiimmiittaattiioonnss 
IItt iiss NNOOTT TTrraannssiittiivvee 
IItt iiss NNOOTT 
AAssssoocciiaattiivvee

More Related Content

What's hot

CS201- Introduction to Programming- Lecture 07
CS201- Introduction to Programming- Lecture 07CS201- Introduction to Programming- Lecture 07
CS201- Introduction to Programming- Lecture 07
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10
Bilal Ahmed
 
Comparative and superlative adjectives
Comparative and superlative adjectivesComparative and superlative adjectives
Comparative and superlative adjectivesLidia Canet
 
Comparative and superlative adjectives
Comparative and superlative adjectivesComparative and superlative adjectives
Comparative and superlative adjectives
Lidia Canet
 
Rational zero of polynomial function
Rational zero of polynomial functionRational zero of polynomial function
Rational zero of polynomial function
Department of Education
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 15
CS201- Introduction to Programming- Lecture 15CS201- Introduction to Programming- Lecture 15
CS201- Introduction to Programming- Lecture 15
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
Bilal Ahmed
 
Perangkat Keras Hardware
Perangkat Keras HardwarePerangkat Keras Hardware
Perangkat Keras Hardware
Johan19931106
 
Hardware
HardwareHardware
Hardware
beneathz
 
pengenalan perangkat keras komputer
pengenalan perangkat keras komputerpengenalan perangkat keras komputer
pengenalan perangkat keras komputer
zee120196
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
Bilal Ahmed
 
Replace your lawn sprinkler controller
Replace your lawn sprinkler controllerReplace your lawn sprinkler controller
Replace your lawn sprinkler controller
GemSprinkler
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
Bilal Ahmed
 

What's hot (19)

CS201- Introduction to Programming- Lecture 07
CS201- Introduction to Programming- Lecture 07CS201- Introduction to Programming- Lecture 07
CS201- Introduction to Programming- Lecture 07
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10
 
Comparative and superlative adjectives
Comparative and superlative adjectivesComparative and superlative adjectives
Comparative and superlative adjectives
 
Comparative and superlative adjectives
Comparative and superlative adjectivesComparative and superlative adjectives
Comparative and superlative adjectives
 
Rational zero of polynomial function
Rational zero of polynomial functionRational zero of polynomial function
Rational zero of polynomial function
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
 
CS201- Introduction to Programming- Lecture 15
CS201- Introduction to Programming- Lecture 15CS201- Introduction to Programming- Lecture 15
CS201- Introduction to Programming- Lecture 15
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
 
Perangkat Keras Hardware
Perangkat Keras HardwarePerangkat Keras Hardware
Perangkat Keras Hardware
 
Hardware
HardwareHardware
Hardware
 
pengenalan perangkat keras komputer
pengenalan perangkat keras komputerpengenalan perangkat keras komputer
pengenalan perangkat keras komputer
 
Perangkat keras komputer
Perangkat keras komputerPerangkat keras komputer
Perangkat keras komputer
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 
Replace your lawn sprinkler controller
Replace your lawn sprinkler controllerReplace your lawn sprinkler controller
Replace your lawn sprinkler controller
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 

Viewers also liked

Yehai catalogue -tracy chow
Yehai catalogue -tracy chowYehai catalogue -tracy chow
Yehai catalogue -tracy chow
slideroma
 
Wall quote vinyl decal
Wall quote vinyl decalWall quote vinyl decal
Wall quote vinyl decal
vinyldecors
 
Bab i, ii, iii
Bab i, ii, iiiBab i, ii, iii
Bab i, ii, iii
Nur Alfiyatur Rochmah
 
CS201- Introduction to Programming- Lecture 05
CS201- Introduction to Programming- Lecture 05CS201- Introduction to Programming- Lecture 05
CS201- Introduction to Programming- Lecture 05
Bilal Ahmed
 
Professionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility managementProfessionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility management
Orbid
 
Mtm terbaru 02 06-2014 (2)
Mtm terbaru 02 06-2014 (2)Mtm terbaru 02 06-2014 (2)
Mtm terbaru 02 06-2014 (2)
Nur Alfiyatur Rochmah
 
Untuk presentasi
Untuk presentasi Untuk presentasi
Untuk presentasi
Nur Alfiyatur Rochmah
 
CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20
Bilal Ahmed
 
Kid’s party decorations ideas
Kid’s party decorations ideasKid’s party decorations ideas
Kid’s party decorations ideas
JoeCavallaro
 
Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online
JoeCavallaro
 
Poto copian pemahaman studi hukum islam
Poto copian pemahaman studi hukum islamPoto copian pemahaman studi hukum islam
Poto copian pemahaman studi hukum islam
Nur Alfiyatur Rochmah
 
ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31
Bilal Ahmed
 
Studi hukum islam
Studi hukum islamStudi hukum islam
Studi hukum islam
Nur Alfiyatur Rochmah
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
Bilal Ahmed
 
Aml catalogue 13
Aml catalogue 13Aml catalogue 13
Aml catalogue 13
slideroma
 
Aga power softcase catalog
Aga power softcase catalogAga power softcase catalog
Aga power softcase catalog
slideroma
 
MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37
Bilal Ahmed
 
Botón de mano y volante de mano
Botón de mano y volante de manoBotón de mano y volante de mano
Botón de mano y volante de mano
Francisco Melgarejo Rodriguez
 

Viewers also liked (20)

Yehai catalogue -tracy chow
Yehai catalogue -tracy chowYehai catalogue -tracy chow
Yehai catalogue -tracy chow
 
Wall quote vinyl decal
Wall quote vinyl decalWall quote vinyl decal
Wall quote vinyl decal
 
Bab i, ii, iii
Bab i, ii, iiiBab i, ii, iii
Bab i, ii, iii
 
CS201- Introduction to Programming- Lecture 05
CS201- Introduction to Programming- Lecture 05CS201- Introduction to Programming- Lecture 05
CS201- Introduction to Programming- Lecture 05
 
Shi pemahaman hukum islam
Shi pemahaman hukum islamShi pemahaman hukum islam
Shi pemahaman hukum islam
 
Professionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility managementProfessionaliseer uw technische dienst en facility management
Professionaliseer uw technische dienst en facility management
 
Mtm terbaru 02 06-2014 (2)
Mtm terbaru 02 06-2014 (2)Mtm terbaru 02 06-2014 (2)
Mtm terbaru 02 06-2014 (2)
 
Untuk presentasi
Untuk presentasi Untuk presentasi
Untuk presentasi
 
CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20CS201- Introduction to Programming- Lecture 20
CS201- Introduction to Programming- Lecture 20
 
Kid’s party decorations ideas
Kid’s party decorations ideasKid’s party decorations ideas
Kid’s party decorations ideas
 
Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online Kids Party Decoration Supplies Online
Kids Party Decoration Supplies Online
 
Poto copian pemahaman studi hukum islam
Poto copian pemahaman studi hukum islamPoto copian pemahaman studi hukum islam
Poto copian pemahaman studi hukum islam
 
ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31ENG101- English Comprehension- Lecture 31
ENG101- English Comprehension- Lecture 31
 
Studi hukum islam
Studi hukum islamStudi hukum islam
Studi hukum islam
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
 
Aml catalogue 13
Aml catalogue 13Aml catalogue 13
Aml catalogue 13
 
Aga power softcase catalog
Aga power softcase catalogAga power softcase catalog
Aga power softcase catalog
 
Hukum islam
Hukum islamHukum islam
Hukum islam
 
MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37MGT101 - Financial Accounting- Lecture 37
MGT101 - Financial Accounting- Lecture 37
 
Botón de mano y volante de mano
Botón de mano y volante de manoBotón de mano y volante de mano
Botón de mano y volante de mano
 

Similar to CS201- Introduction to Programming- Lecture 29

CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22
Bilal Ahmed
 
Industrialisasi Media
Industrialisasi MediaIndustrialisasi Media
Industrialisasi Media
University of Andalas
 
Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017Rajeev Sharma
 
Hardware
HardwareHardware
Hardware
rahmanitayulia
 
MODUL 1 - PERANGKAT KERAS
MODUL 1 - PERANGKAT KERASMODUL 1 - PERANGKAT KERAS
MODUL 1 - PERANGKAT KERAS
Benar Setya
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
Bilal Ahmed
 
Strategies for representing whistleblowers in the federal government
Strategies for representing whistleblowers in the federal governmentStrategies for representing whistleblowers in the federal government
Strategies for representing whistleblowers in the federal government
Zuckerman Law Whistleblower Protection Law Firm
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
Bilal Ahmed
 
Hafitz_Rizki 201343500823 Java_dan_Database_Mysql
Hafitz_Rizki 201343500823 Java_dan_Database_MysqlHafitz_Rizki 201343500823 Java_dan_Database_Mysql
Hafitz_Rizki 201343500823 Java_dan_Database_Mysql
Muhamad Hafitz Rizki
 
Detectia prezentei Salmonella spp prin real time PCR
Detectia prezentei Salmonella spp prin real time PCRDetectia prezentei Salmonella spp prin real time PCR
Detectia prezentei Salmonella spp prin real time PCR
Institutul Pasteur
 
Software engineering
Software engineeringSoftware engineering
Software engineeringOdin Onyenk
 
CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08
Bilal Ahmed
 
Fluid & electrolytes & acid base
Fluid & electrolytes & acid baseFluid & electrolytes & acid base
Fluid & electrolytes & acid base
Michelle Harris
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
Bilal Ahmed
 
Osteo osteomalacia ricket2
Osteo osteomalacia ricket2Osteo osteomalacia ricket2
Osteo osteomalacia ricket2padli ahmad
 
Glaucoma
GlaucomaGlaucoma
Glaucoma
Other Mother
 

Similar to CS201- Introduction to Programming- Lecture 29 (20)

CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
 
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22
 
Industrialisasi Media
Industrialisasi MediaIndustrialisasi Media
Industrialisasi Media
 
Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017
 
Hardware
HardwareHardware
Hardware
 
MODUL 1 - PERANGKAT KERAS
MODUL 1 - PERANGKAT KERASMODUL 1 - PERANGKAT KERAS
MODUL 1 - PERANGKAT KERAS
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
 
Strategies for representing whistleblowers in the federal government
Strategies for representing whistleblowers in the federal governmentStrategies for representing whistleblowers in the federal government
Strategies for representing whistleblowers in the federal government
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
Hafitz_Rizki 201343500823 Java_dan_Database_Mysql
Hafitz_Rizki 201343500823 Java_dan_Database_MysqlHafitz_Rizki 201343500823 Java_dan_Database_Mysql
Hafitz_Rizki 201343500823 Java_dan_Database_Mysql
 
Detectia prezentei Salmonella spp prin real time PCR
Detectia prezentei Salmonella spp prin real time PCRDetectia prezentei Salmonella spp prin real time PCR
Detectia prezentei Salmonella spp prin real time PCR
 
ram new
ram newram new
ram new
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08
 
Fluid & electrolytes & acid base
Fluid & electrolytes & acid baseFluid & electrolytes & acid base
Fluid & electrolytes & acid base
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
Osteo osteomalacia ricket2
Osteo osteomalacia ricket2Osteo osteomalacia ricket2
Osteo osteomalacia ricket2
 
Derivados biologicos
Derivados biologicosDerivados biologicos
Derivados biologicos
 
Glaucoma
GlaucomaGlaucoma
Glaucoma
 

More from Bilal Ahmed

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16
Bilal Ahmed
 

More from Bilal Ahmed (10)

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
 
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21
 
CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19
 
CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18
 
CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17
 
CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16
 

CS201- Introduction to Programming- Lecture 29

  • 5. FFrriieenndd FFuunnccttiioonn ccllaassss DDaattee {{ ---- ffrriieenndd ffuunnccttiioonnNNaammee (( AArrgguummeenntt__lliisstt )) ;; ---- }} ;;
  • 6. FFrriieenndd FFuunnccttiioonn  FFrriieenndd ffuunnccttiioonnss aarree NNOOTT tthhee mmeemmbbeerrss ooff tthhee ccllaassss  TThhee ccllaassss iittsseellff ddeeccllaarree iitt’’ss ffrriieenndd ffuunnccttiioonnss  TThhee pprroottoottyyppee ooff tthheessee ffuunnccttiioonnss aarree wwrriitttteenn iinnssiiddee tthhee ccllaassss aanndd tthhee kkeeyy wwoorrdd ffrriieenndd iiss aappppeennddeedd bbeeffoorree tthhee ffuunnccttiioonn nnaammee  FFrriieenndd ffuunnccttiioonnss hhaavvee aacccceessss ttoo pprriivvaattee aanndd ppuubblliicc mmeemmbbeerrss ooff tthhee ccllaassss
  • 7. EExxaammppllee 11 ccllaassss mmyyCCllaassss {{ ffrriieenndd iinnccrreemmeenntt (( mmyyCCllaassss ,, iinntt )) ;; pprriivvaattee:: iinntt ttooppSSeeccrreett ;; ppuubblliicc:: mmyyCCllaassss (( )) {{ ttooppSSeeccrreett == 110000 ;; }} vvooiidd DDiissppllaayy (( )) {{ ccoouutt<<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iiss ““ <<<< ttooppSSeeccrreett ;; }} }} ;;
  • 8. EExxaammppllee 11 vvooiidd IInnccrreemmeenntt (( mmyyCCllaassss AA ,, iinntt ii )) {{ AA..ttooppSSeeccrreett ++== ii ;; }}
  • 9. EExxaammppllee 11 mmaaiinn (( )) {{ mmyyCCllaassss xx ;; xx..DDiissppllaayy (( )) ;; IInnccrreemmeenntt (( xx ,, 1100 )) ;; xx..DDiissppllaayy (( )) ;; }}
  • 10. EExxaammppllee 11:: OOuuttppuutt TThhee vvaalluuee ooff ttooppSSeeccrreett iiss 110000 TThhee vvaalluuee ooff ttooppSSeeccrreett iiss 111100
  • 11. EExxaammppllee 22 ccllaassss mmyyCCllaassssTTwwoo ;; ccllaassss mmyyCCllaassssOOnnee {{ pprriivvaattee :: iinntt ttooppSSeeccrreett ;; ppuubblliicc :: vvooiidd DDiissppllaayy (( )) ;; mmyyCCllaassssOOnnee (( )) {{ ttooppSSeeccrreett == 110000;; }} ffrriieenndd AAddddBBootthh (( mmyyCCllaassssOOnnee ,, mmyyCCllaassssTTwwoo )) ;; }} ;;
  • 12. EExxaammppllee 22 ccllaassss mmyyCCllaassssTTwwoo {{ pprriivvaattee:: iinntt ttooppSSeeccrreett ;; ppuubblliicc:: vvooiidd DDiissppllaayy (( )) ;; mmyyCCllaassssTTwwoo (( )) {{ ttooppSSeeccrreett == 220000 ;; }} ffrriieenndd AAddddBBootthh (( mmyyCCllaassssOOnnee ,, mmyyCCllaassssTTwwoo )) ;; }} ;;
  • 13. EExxaammppllee 22 mmaaiinn (( )) {{ mmyyCCllaassssOOnnee AA ;; mmyyCCllaassssTTwwoo BB ;; AA..DDiissppllaayy (( )) ;; BB..DDiissppllaayy (( )) ;; AAddddBBootthh (( AA ,, BB )) ;; }}
  • 14. EExxaammppllee 22 iinntt AAddddBBootthh (( mmyyCCllaassssOOnnee AA ,, mmyyCCllaassssTTwwoo BB )) {{ ccoouutt <<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iinn mmyyCCllaassssOOnnee oobbjjeecctt iiss”” <<<< AA..ttooppSSeeccrreett ;; ccoouutt <<<< ““TThhee vvaalluuee ooff ttooppSSeeccrreett iinn mmyyCCllaassssTTwwoo oobbjjeecctt iiss””<<<< BB..ttooppSSeeccrreett ;; ccoouutt <<<< ““TThhee ssuumm ooff ttooppSSeeccrreett vvaalluueess iinn ““ <<<< ““mmyyCCllaassssOOnnee aanndd mmyyCCllaassssTTwwoo oobbjjeecctt iiss ”” <<<< AA..ttooppSSeeccrreett ++ BB..ttooppSSeeccrreett ;; }}
  • 15. EExxaammppllee 33 ccllaassss ootthheerrCCllaassss ;; ccllaassss ccllaassssOOnnee {{ pprriivvaattee :: iinntt ttooppSSeeccrreett;; ppuubblliicc :: vvooiidd DDiissppllaayy (( )) ;; ccllaassssOOnnee (( )) {{ TTooppSSeeccrreett == 110000 ;; }} ffrriieenndd ootthheerrCCllaassss ;; }} ;;
  • 16. SSttrraaiigghhtt LLiinnee yy == mmxx ++ cc Slope Intercept on y axis
  • 17. SSttrraaiigghhtt LLiinnee ccllaassss ssttrraaiigghhttLLiinnee {{ ddoouubbllee ssllooppee ,, iinntteerrcceepptt ;; //// mmeemmbbeerr ffuunnccttiioonn }} ;;
  • 18. QQuuaaddrraattiicc yy == aaxx22 ++bbxx ++ cc
  • 19. QQuuaaddrraattiicc ccllaassss qquuaaddrraattiicc {{ pprriivvaattee :: ddoouubbllee aa ,, bb ,, cc ;; //// mmeemmbbeerr ffuunnccttiioonn }} ;;
  • 20. LLiimmiittaattiioonnss IItt iiss NNOOTT TTrraannssiittiivvee IItt iiss NNOOTT AAssssoocciiaattiivvee