SlideShare une entreprise Scribd logo
1  sur  28
Introduction ttoo PPrrooggrraammmmiinngg 
LLeeccttuurree 4400
CCllaassss 
CCllaassss iiss aa uusseerr 
ddeeffiinneedd ddaattaa ttyyppee..
DDaattaa 
HHiiddiinngg
PPuubblliicc 
IInntteerrffaaccee
Yes yyoouu ccaann uussee uusseerr 
ddeeffiinneedd ddaattaa ttyyppee aass aa 
mmeemmbbeerr ooff tthhee ccllaassss 
CCllaassss ccaann ccoonnttaaiinn 
oobbjjeeccttss..
EExxaammppllee 
ccllaassss DDaattee 
{{ 
pprriivvaattee :: 
iinntt mmoonntthh ,, ddaayy ,, yyeeaarr 
;; 
ppuubblliicc :: 
//// mmeemmbbeerr ffuunnccttiioonnss 
}} ;;
EExxaammppllee 
ccllaassss PPeerrssoonn 
{{ 
pprriivvaattee :: 
cchhaarr ** nnaammee ;; 
cchhaarr ** aaddddrreessss ;; 
DDaattee ddaatteeOOffBBiirrtthh ;; //// mmeemmbbeerr oobbjjeecctt 
ppuubblliicc :: 
//// ppuubblliicc mmeemmbbeerr ffuunnccttiioonnss .. .. .. 
}} ;;
Person :: Person ( char * name , char * address , int day , int mmoonntthh ,, iinntt yyeeaarr {{ 
ddaatteeOOffBBiirrtthh..sseettDDaayy (( ddyy )) ;; 
ddaatteeOOffBBiirrtthh..sseettMMoonntthh (( mmnn )) ;; 
ddaatteeOOffBBiirrtthh..sseettYYeeaarr (( yyrr )) ;; 
//// ssttaatteemmeenntt (( ss )) ;; 
}}
IInniittiiaalliizzeerr 
LLiisstt
Person :: Person (( cchhaarr ** nnaammee ,, 
cchhaarr ** aaddddrreessss ,, iinntt ddaayy,, iinntt mmoonntthh,, iinntt yyeeaarr )) 
:: DDaattee (( iinntt mmoonntthh ,, iinntt ddaayy ,, iinntt yyeeaarr ))
CCoonnssttrruuccttoorr 
DDaattee :::: DDaattee (( iinntt ddaayy ,, iinntt mmoonntthh ,, iinntt yyeeaarr )) 
{{ 
ccoouutt <<<< ““IInnssiiddee DDaattee ccoonnssttrruuccttoorr ”” ;; 
}} 
PPeerrssoonn :::: PPeerrssoonn (( cchhaarr ** nnaammee ,, cchhaarr ** aaddddrreessss ,,iinntt ddaayy ,, 
iinntt mmoonntthh ,, iinntt yyeeaarr )) :: DDaattee (( mmoonntthh ,, ddaayy ,, yyeeaarr )) 
{{ 
ccoouutt <<<< ““IInnssiiddee PPeerrssoonn ccoonnssttrruuccttoorr”” ;; 
}}
DDeessttrruuccttoorr 
~~ DDaattee (( )) 
{{ 
ccoouutt <<<< ““IInnssiiddee DDaattee ddeessttrruuccttoorr ”” ;; 
}} 
~~ PPeerrssoonn (( )) 
{{ 
ccoouutt <<<< ““IInnssiiddee PPeerrssoonn ddeessttrruuccttoorr”” ;; 
}}
EExxaammppllee ccllaassss CCoolluummnn 
{{ 
pprriivvaattee :: 
iinntt ssiizzee ;; 
ppuubblliicc :: 
CCoolluummnn (( )) 
{{ 
ccoouutt <<<< ""CCoolluummnn CCrreeaatteedd"" <<<< eennddll ;; 
}} 
vvooiidd ddiissppllaayy (( )) ;; 
vvooiidd sseett (( iinntt )) ;; 
~~ CCoolluummnn (( )) 
{{ 
ccoouutt <<<< ""CCoolluummnn ddeessttrrooyyeedd"" <<<< eennddll ;; 
}} 
}} ;;
EExxaammppllee ccllaassss RRooww 
{{ 
pprriivvaattee :: 
iinntt ssiizzee ;; 
CCoolluummnn ccooll ;; 
ppuubblliicc :: 
vvooiidd sseett (( iinntt )) ;; 
RRooww (( )) 
{{ 
ccoouutt <<<< ""IInnssiiddee CCoonnssttrruuccttoorr ffoorr oobbjjeecctt RRooww"" <<<< eennddll ;; 
}} 
~~ RRooww (( )) 
{{ 
ccoouutt <<<< ""RRooww ddeessttrrooyyeedd"" <<<< eennddll ;; 
}} 
vvooiidd ddiissppllaayy (( )) ;; 
}} ;;
EExxaammppllee ccllaassss MMaattrriixx 
{{ 
pprriivvaattee :: 
RRooww rrooww ;; 
iinntt ssiizzee ;; 
ppuubblliicc :: 
MMaattrriixx (( )) 
{{ 
ccoouutt <<<< ""MMaattrriixx CCrreeaatteedd"" <<<< eennddll <<<< eennddll ;; 
}} 
~~ MMaattrriixx (( )) 
{{ 
ccoouutt <<<< ""MMaattrriixx ddeessttrrooyyeedd"" <<<< eennddll <<<< eennddll ;; 
}} 
vvooiidd ddiissppllaayy (( )) ;; 
}} ;;
EExxaammppllee 
mmaaiinn(( )) 
{{ 
MMaattrriixx mm ;; 
mm..ddiissppllaayy (( )) ;; 
}}
OOuuttppuutt 
CCoolluummnn CCrreeaatteedd 
IInnssiiddee CCoonnssttrruuccttoorr ffoorr oobbjjeecctt RRooww 
MMaattrriixx CCrreeaatteedd 
…….. 
MMaattrriixx DDeessttrrooyyeedd 
RRooww DDeessttrrooyyeedd 
CCoolluummnn DDeessttrrooyyeedd
CCooddee 
RReeuussee
ccoonnsstt DDaattee 
ddaatteeOOffBBiirrtthh ;;
SSttrruuccttuurree iinnssiiddee 
aa ssttrruuccttuurree
CCllaassss 
iinnssiiddee aa 
ccllaassss
EExxaammppllee 
ccllaassss OOuutteerr 
{{ 
………….. 
ccllaassss IInnnneerr11 
{{ 
pprriivvaattee :: 
//// DDaattaa mmeemmbbeerrss 
////ddaattaa ffuunnccttiioonnss 
ppuubblliicc :: 
//// DDaattaa mmeemmbbeerrss 
////ddaattaa ffuunnccttiioonnss 
}} ;; 
////ddaattaa mmeemmbbeerrss 
////ddaattaa ffuunnccttiioonnss 
}} ;;
CCllaassss iinnssiiddee aa 
ccllaassss 
Inner2 
Inner1 
Outer
FFrriieenndd
EExxaammppllee 
ccllaassss OOuutteerr 
{{ 
ppuubblliicc :: 
ccllaassss IInnnneerr ;; 
ffrriieenndd ccllaassss IInnnneerr ;; 
ccllaassss IInnnneerr 
{{ 
ffrriieenndd ccllaassss oouutteerr ;; 
//// DDaattaa mmeemmbbeerrss 
}};; 
//// DDaattaa mmeemmbbeerrss 
//// MMeemmbbeerr ffuunnccttiioonnss 
}} ;;
ReturnType className :::: ffuunnccttiioonnNNaammee (( )) 
{{ 
//// SSttaatteemmeenntt (( ss )) ;; ddeeffiinniittiioonn 
}} }
Outer :: IInnnneerr :::: IInnnneerr (( )) 
{{ 
//// ddeeffiinniittiioonn 
}}
EExxaammppllee 
ccllaassss OOuutteerr 
{{ 
ccllaassss IInnnneerr11 
{{ 
ccllaassss IInnnneerr22 
{{ 
ccllaassss IInnnneerr33 
{{ 
//// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss 
//// aanndd ppeerrhhaappss mmoorree iinnnneerr ccllaasssseess 
}} ;; 
//// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss 
}} ;; 
//// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss 
}} ;; 
}} ;; 
48:

Contenu connexe

Tendances

pengenalan perangkat keras komputer
pengenalan perangkat keras komputerpengenalan perangkat keras komputer
pengenalan perangkat keras komputer
zee120196
 

Tendances (19)

21 High-quality programming code construction part-ii
21 High-quality programming code construction part-ii21 High-quality programming code construction part-ii
21 High-quality programming code construction part-ii
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16
 
Ankit
AnkitAnkit
Ankit
 
CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03
 
19 Algorithms and complexity
19 Algorithms and complexity19 Algorithms and complexity
19 Algorithms and complexity
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
 
CS201- Introduction to Programming- Lecture 12
CS201- Introduction to Programming- Lecture 12CS201- Introduction to Programming- Lecture 12
CS201- Introduction to Programming- Lecture 12
 
Grade 12 U0-L4-GraphicalMethods
Grade 12 U0-L4-GraphicalMethodsGrade 12 U0-L4-GraphicalMethods
Grade 12 U0-L4-GraphicalMethods
 
Hardware
HardwareHardware
Hardware
 
Perangkat Keras Hardware
Perangkat Keras HardwarePerangkat Keras Hardware
Perangkat Keras 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 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
 
4th grade, lesson plan
4th grade, lesson plan4th grade, lesson plan
4th grade, lesson plan
 
CS201- Introduction to Programming- Lecture 04
CS201- Introduction to Programming- Lecture 04CS201- Introduction to Programming- Lecture 04
CS201- Introduction to Programming- Lecture 04
 
Grade 12 U0-L3-ErrorEstimation
Grade 12 U0-L3-ErrorEstimationGrade 12 U0-L3-ErrorEstimation
Grade 12 U0-L3-ErrorEstimation
 
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 11
CS201- Introduction to Programming- Lecture 11CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11
 

En vedette

Global Citizenship Digest- 2010 Winter
Global Citizenship Digest- 2010 WinterGlobal Citizenship Digest- 2010 Winter
Global Citizenship Digest- 2010 Winter
Eva Aboagye
 

En vedette (19)

ENG101- English Comprehension- Lecture 38
ENG101- English Comprehension- Lecture 38ENG101- English Comprehension- Lecture 38
ENG101- English Comprehension- Lecture 38
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
 
CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17CS201- Introduction to Programming- Lecture 17
CS201- Introduction to Programming- Lecture 17
 
MGT101 - Financial Accounting- Lecture 35
MGT101 - Financial Accounting- Lecture 35MGT101 - Financial Accounting- Lecture 35
MGT101 - Financial Accounting- Lecture 35
 
CS101- Introduction to Computing- Lecture 36
CS101- Introduction to Computing- Lecture 36CS101- Introduction to Computing- Lecture 36
CS101- Introduction to Computing- Lecture 36
 
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 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
MGT101 - Financial Accounting- Lecture 23
MGT101 - Financial Accounting- Lecture 23MGT101 - Financial Accounting- Lecture 23
MGT101 - Financial Accounting- Lecture 23
 
ENG101- English Comprehension- Lecture 26
ENG101- English Comprehension- Lecture 26ENG101- English Comprehension- Lecture 26
ENG101- English Comprehension- Lecture 26
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45
 
MGT101 - Financial Accounting- Lecture 32
MGT101 - Financial Accounting- Lecture 32MGT101 - Financial Accounting- Lecture 32
MGT101 - Financial Accounting- Lecture 32
 
CS101- Introduction to Computing- Lecture 25
CS101- Introduction to Computing- Lecture 25CS101- Introduction to Computing- Lecture 25
CS101- Introduction to Computing- Lecture 25
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
 
CS101- Introduction to Computing- Lecture 28
CS101- Introduction to Computing- Lecture 28CS101- Introduction to Computing- Lecture 28
CS101- Introduction to Computing- Lecture 28
 
Making information easy for voters
Making information easy for votersMaking information easy for voters
Making information easy for voters
 
Global Citizenship Digest- 2010 Winter
Global Citizenship Digest- 2010 WinterGlobal Citizenship Digest- 2010 Winter
Global Citizenship Digest- 2010 Winter
 
Irr verbs21 2_sl
Irr verbs21 2_slIrr verbs21 2_sl
Irr verbs21 2_sl
 
STROFFOLINO_eng
STROFFOLINO_engSTROFFOLINO_eng
STROFFOLINO_eng
 
Designing a ballot: art AND science
Designing a ballot: art AND scienceDesigning a ballot: art AND science
Designing a ballot: art AND science
 

Similaire à CS201- Introduction to Programming- Lecture 40

Dielectrics lect28
Dielectrics lect28Dielectrics lect28
Dielectrics lect28
Joao Tan
 
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014 Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
Stuart Meachem
 
Osteo osteomalacia ricket2
Osteo osteomalacia ricket2Osteo osteomalacia ricket2
Osteo osteomalacia ricket2
padli ahmad
 

Similaire à CS201- Introduction to Programming- Lecture 40 (20)

CS201- Introduction to Programming- Lecture 09
CS201- Introduction to Programming- Lecture 09CS201- Introduction to Programming- Lecture 09
CS201- Introduction to Programming- Lecture 09
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
 
Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
 Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
Parecer Técnico-Científicodo perito independente Leví Inimá de Miranda
 
Dielectrics lect28
Dielectrics lect28Dielectrics lect28
Dielectrics lect28
 
TOP Downloaded Papers (January)--International Journal of Computer Networks &...
TOP Downloaded Papers (January)--International Journal of Computer Networks &...TOP Downloaded Papers (January)--International Journal of Computer Networks &...
TOP Downloaded Papers (January)--International Journal of Computer Networks &...
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
 
ashraf final year ppt on wcr drm kota
ashraf final year ppt on wcr drm kotaashraf final year ppt on wcr drm kota
ashraf final year ppt on wcr drm kota
 
CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18CS201- Introduction to Programming- Lecture 18
CS201- Introduction to Programming- Lecture 18
 
CheckFood - startup pitch-updated
CheckFood  - startup pitch-updatedCheckFood  - startup pitch-updated
CheckFood - startup pitch-updated
 
Dess courtier
Dess courtierDess courtier
Dess courtier
 
Sindrome de embolismo graso
Sindrome de embolismo grasoSindrome de embolismo graso
Sindrome de embolismo graso
 
sculpture
sculpturesculpture
sculpture
 
Contract labour act_673
Contract labour act_673   Contract labour act_673
Contract labour act_673
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
 
No Degree, No Problem
No Degree, No ProblemNo Degree, No Problem
No Degree, No Problem
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
 
Cataract and implant surgery
Cataract and implant surgeryCataract and implant surgery
Cataract and implant surgery
 
Training methods
Training methodsTraining methods
Training methods
 
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014 Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
Wattle Grove Primary School - Year 7 Kalgoorlie Camp 2014
 
Osteo osteomalacia ricket2
Osteo osteomalacia ricket2Osteo osteomalacia ricket2
Osteo osteomalacia ricket2
 

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 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 
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 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22
 
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 40

  • 2. CCllaassss CCllaassss iiss aa uusseerr ddeeffiinneedd ddaattaa ttyyppee..
  • 5. Yes yyoouu ccaann uussee uusseerr ddeeffiinneedd ddaattaa ttyyppee aass aa mmeemmbbeerr ooff tthhee ccllaassss CCllaassss ccaann ccoonnttaaiinn oobbjjeeccttss..
  • 6. EExxaammppllee ccllaassss DDaattee {{ pprriivvaattee :: iinntt mmoonntthh ,, ddaayy ,, yyeeaarr ;; ppuubblliicc :: //// mmeemmbbeerr ffuunnccttiioonnss }} ;;
  • 7. EExxaammppllee ccllaassss PPeerrssoonn {{ pprriivvaattee :: cchhaarr ** nnaammee ;; cchhaarr ** aaddddrreessss ;; DDaattee ddaatteeOOffBBiirrtthh ;; //// mmeemmbbeerr oobbjjeecctt ppuubblliicc :: //// ppuubblliicc mmeemmbbeerr ffuunnccttiioonnss .. .. .. }} ;;
  • 8. Person :: Person ( char * name , char * address , int day , int mmoonntthh ,, iinntt yyeeaarr {{ ddaatteeOOffBBiirrtthh..sseettDDaayy (( ddyy )) ;; ddaatteeOOffBBiirrtthh..sseettMMoonntthh (( mmnn )) ;; ddaatteeOOffBBiirrtthh..sseettYYeeaarr (( yyrr )) ;; //// ssttaatteemmeenntt (( ss )) ;; }}
  • 10. Person :: Person (( cchhaarr ** nnaammee ,, cchhaarr ** aaddddrreessss ,, iinntt ddaayy,, iinntt mmoonntthh,, iinntt yyeeaarr )) :: DDaattee (( iinntt mmoonntthh ,, iinntt ddaayy ,, iinntt yyeeaarr ))
  • 11. CCoonnssttrruuccttoorr DDaattee :::: DDaattee (( iinntt ddaayy ,, iinntt mmoonntthh ,, iinntt yyeeaarr )) {{ ccoouutt <<<< ““IInnssiiddee DDaattee ccoonnssttrruuccttoorr ”” ;; }} PPeerrssoonn :::: PPeerrssoonn (( cchhaarr ** nnaammee ,, cchhaarr ** aaddddrreessss ,,iinntt ddaayy ,, iinntt mmoonntthh ,, iinntt yyeeaarr )) :: DDaattee (( mmoonntthh ,, ddaayy ,, yyeeaarr )) {{ ccoouutt <<<< ““IInnssiiddee PPeerrssoonn ccoonnssttrruuccttoorr”” ;; }}
  • 12. DDeessttrruuccttoorr ~~ DDaattee (( )) {{ ccoouutt <<<< ““IInnssiiddee DDaattee ddeessttrruuccttoorr ”” ;; }} ~~ PPeerrssoonn (( )) {{ ccoouutt <<<< ““IInnssiiddee PPeerrssoonn ddeessttrruuccttoorr”” ;; }}
  • 13. EExxaammppllee ccllaassss CCoolluummnn {{ pprriivvaattee :: iinntt ssiizzee ;; ppuubblliicc :: CCoolluummnn (( )) {{ ccoouutt <<<< ""CCoolluummnn CCrreeaatteedd"" <<<< eennddll ;; }} vvooiidd ddiissppllaayy (( )) ;; vvooiidd sseett (( iinntt )) ;; ~~ CCoolluummnn (( )) {{ ccoouutt <<<< ""CCoolluummnn ddeessttrrooyyeedd"" <<<< eennddll ;; }} }} ;;
  • 14. EExxaammppllee ccllaassss RRooww {{ pprriivvaattee :: iinntt ssiizzee ;; CCoolluummnn ccooll ;; ppuubblliicc :: vvooiidd sseett (( iinntt )) ;; RRooww (( )) {{ ccoouutt <<<< ""IInnssiiddee CCoonnssttrruuccttoorr ffoorr oobbjjeecctt RRooww"" <<<< eennddll ;; }} ~~ RRooww (( )) {{ ccoouutt <<<< ""RRooww ddeessttrrooyyeedd"" <<<< eennddll ;; }} vvooiidd ddiissppllaayy (( )) ;; }} ;;
  • 15. EExxaammppllee ccllaassss MMaattrriixx {{ pprriivvaattee :: RRooww rrooww ;; iinntt ssiizzee ;; ppuubblliicc :: MMaattrriixx (( )) {{ ccoouutt <<<< ""MMaattrriixx CCrreeaatteedd"" <<<< eennddll <<<< eennddll ;; }} ~~ MMaattrriixx (( )) {{ ccoouutt <<<< ""MMaattrriixx ddeessttrrooyyeedd"" <<<< eennddll <<<< eennddll ;; }} vvooiidd ddiissppllaayy (( )) ;; }} ;;
  • 16. EExxaammppllee mmaaiinn(( )) {{ MMaattrriixx mm ;; mm..ddiissppllaayy (( )) ;; }}
  • 17. OOuuttppuutt CCoolluummnn CCrreeaatteedd IInnssiiddee CCoonnssttrruuccttoorr ffoorr oobbjjeecctt RRooww MMaattrriixx CCrreeaatteedd …….. MMaattrriixx DDeessttrrooyyeedd RRooww DDeessttrrooyyeedd CCoolluummnn DDeessttrrooyyeedd
  • 22. EExxaammppllee ccllaassss OOuutteerr {{ ………….. ccllaassss IInnnneerr11 {{ pprriivvaattee :: //// DDaattaa mmeemmbbeerrss ////ddaattaa ffuunnccttiioonnss ppuubblliicc :: //// DDaattaa mmeemmbbeerrss ////ddaattaa ffuunnccttiioonnss }} ;; ////ddaattaa mmeemmbbeerrss ////ddaattaa ffuunnccttiioonnss }} ;;
  • 23. CCllaassss iinnssiiddee aa ccllaassss Inner2 Inner1 Outer
  • 25. EExxaammppllee ccllaassss OOuutteerr {{ ppuubblliicc :: ccllaassss IInnnneerr ;; ffrriieenndd ccllaassss IInnnneerr ;; ccllaassss IInnnneerr {{ ffrriieenndd ccllaassss oouutteerr ;; //// DDaattaa mmeemmbbeerrss }};; //// DDaattaa mmeemmbbeerrss //// MMeemmbbeerr ffuunnccttiioonnss }} ;;
  • 26. ReturnType className :::: ffuunnccttiioonnNNaammee (( )) {{ //// SSttaatteemmeenntt (( ss )) ;; ddeeffiinniittiioonn }} }
  • 27. Outer :: IInnnneerr :::: IInnnneerr (( )) {{ //// ddeeffiinniittiioonn }}
  • 28. EExxaammppllee ccllaassss OOuutteerr {{ ccllaassss IInnnneerr11 {{ ccllaassss IInnnneerr22 {{ ccllaassss IInnnneerr33 {{ //// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss //// aanndd ppeerrhhaappss mmoorree iinnnneerr ccllaasssseess }} ;; //// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss }} ;; //// DDaattaa mmeemmbbeerrss aanndd ffuunnccttiioonnss }} ;; }} ;; 48: