SlideShare une entreprise Scribd logo
1  sur  20
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

Contenu connexe

Tendances

Comparative and superlative adjectives
Comparative and superlative adjectivesComparative and superlative adjectives
Comparative and superlative adjectives
Lidia Canet
 
pengenalan perangkat keras komputer
pengenalan perangkat keras komputerpengenalan perangkat keras komputer
pengenalan perangkat keras komputer
zee120196
 

Tendances (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
 

En vedette

Yehai catalogue -tracy chow
Yehai catalogue -tracy chowYehai catalogue -tracy chow
Yehai catalogue -tracy chow
slideroma
 
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
 
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
 

En vedette (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
 

Similaire à CS201- Introduction to Programming- Lecture 29

Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017Rajeev Sharma Resume 2017
Rajeev Sharma Resume 2017
Rajeev Sharma
 
Software engineering
Software engineeringSoftware engineering
Software engineering
Odin Onyenk
 
Osteo osteomalacia ricket2
Osteo osteomalacia ricket2Osteo osteomalacia ricket2
Osteo osteomalacia ricket2
padli ahmad
 

Similaire à 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
 

Plus de Bilal Ahmed

Plus de 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
 

Dernier

Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergiaImmunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
Pasi Vilpas
 

Dernier (9)

Jedhi Malee (just do it).pdf
Jedhi Malee             (just do it).pdfJedhi Malee             (just do it).pdf
Jedhi Malee (just do it).pdf
 
Oppimateriaaleihin, menetelmiin ja sovelluksiin tutustuminen 2.5.24
Oppimateriaaleihin, menetelmiin ja sovelluksiin tutustuminen 2.5.24Oppimateriaaleihin, menetelmiin ja sovelluksiin tutustuminen 2.5.24
Oppimateriaaleihin, menetelmiin ja sovelluksiin tutustuminen 2.5.24
 
Tutkimus-, kehittämis- ja innovaatiotoiminnan rahoitus
Tutkimus-, kehittämis- ja innovaatiotoiminnan rahoitusTutkimus-, kehittämis- ja innovaatiotoiminnan rahoitus
Tutkimus-, kehittämis- ja innovaatiotoiminnan rahoitus
 
Koulutuksen palkat ja kustannukset sekä koulutuksen ansiot
Koulutuksen palkat ja kustannukset sekä koulutuksen ansiotKoulutuksen palkat ja kustannukset sekä koulutuksen ansiot
Koulutuksen palkat ja kustannukset sekä koulutuksen ansiot
 
Kasvatus, koulutus, opetus ja osaaminen Suomessa
Kasvatus, koulutus, opetus ja osaaminen SuomessaKasvatus, koulutus, opetus ja osaaminen Suomessa
Kasvatus, koulutus, opetus ja osaaminen Suomessa
 
Koulutuksen rahoitus, tulot, menot ja talous
Koulutuksen rahoitus, tulot, menot ja talousKoulutuksen rahoitus, tulot, menot ja talous
Koulutuksen rahoitus, tulot, menot ja talous
 
Aikuiskoulutus, jatkuva oppiminen, elinikäinen oppiminen ja henkilöstökoulutus
Aikuiskoulutus, jatkuva oppiminen, elinikäinen oppiminen ja henkilöstökoulutusAikuiskoulutus, jatkuva oppiminen, elinikäinen oppiminen ja henkilöstökoulutus
Aikuiskoulutus, jatkuva oppiminen, elinikäinen oppiminen ja henkilöstökoulutus
 
Koululaiset, opiskelija, oppijat ja lapset sekä tutkinnot
Koululaiset, opiskelija, oppijat ja lapset sekä tutkinnotKoululaiset, opiskelija, oppijat ja lapset sekä tutkinnot
Koululaiset, opiskelija, oppijat ja lapset sekä tutkinnot
 
Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergiaImmunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
Immunologian perusteet: valkosolutyyppien yhteistyö, elinsiirrot, allergia
 

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