SlideShare a Scribd company logo
1 of 33
Introduction ooff PPrrooggrraammmmiinngg 
LLeeccttuurree 2288
TTooddaayy’’ss 
LLeeccttuurree 
 HHooww mmeemmoorryy aallllooccaattiioonn iiss ddoonnee iinn 
CC++++ 
 HHooww iiss iitt ddiiffffeerreenntt ffrroomm CC ssttyyllee 
 AAddvvaannttaaggeess ooff mmeemmoorryy aallllooccaattiioonn iinn 
CC++++ 
 UUsseess ooff mmeemmoorryy aallllooccaattiioonn 
– CCllaasssseess 
– OObbjjeeccttss
PPooiinntteerrss ttoo aa 
ddaattaa ssttrruuccttuurree
PPooiinntteerrss ttoo aa 
ccllaassss
-->>
MMeemmoorryy 
AAllllooccaattiioonn
mmaalllloocc (( )) ;; 
ccaalllloocc (( )) ;; 
rreeaalllloocc (( )) ;;
malloc ( 10 * ( sizeof (( iinntt )) )) )) ;;
ffrreeee (( ))
nneeww
nneeww iinntt ;;
Example 
iinntt ** iippttrr ;; 
iippttrr == nneeww iinntt ;;
Example 
nneeww cchhaarr ;; 
nneeww ddoouubbllee ;;
ddeelleettee
Example 
iinntt ** iippttrr ;; 
iippttrr == nneeww iinntt ;; 
ddeelleettee iippttrr ;;
Example 
iinntt ** iippttrr ;; 
iippttrr == nneeww iinntt [[ 1100 ]] ;;
Example 
new data_type [ Number_ooff__llooccaattiioonnss ]] ;; 
nneeww ddoouubbllee [[ 1100 ]] ;;
EExxaammppllee 
iinntt **iippttrr ;; 
iippttrr == nneeww iinntt [[ 1100 ]] ;; 
ddeelleettee iippttrr ;;
EExxaammppllee 
DDaattee **ddppttrr ;; 
ddppttrr iiss aa ppooiinntteerr ttoo aann oobbjjeecctt ooff ttyyppee ddaattee
ddppttrr == nneeww DDaattee ;;
mmaaiinn (( )) 
{{ 
DDaattee mmyyddaattee ;; 
ccoouutt<<<< ssiizzeeooff (( mmyyddaattee )) ;; 
}} 
EExxaammppllee
EExxaammppllee 
iinntt **iippttrr ;; 
iippttrr == nneeww iinntt [[ 1100 ]] ;;
EExxaammppllee 
DDaattee **ddppttrr ;; 
ddppttrr == nneeww DDaattee [[ 1100 ]] ;;
EExxaammppllee 
DDaattee ddaattee11 ,, **ddppttrr ;; 
ddaattee11..sseettDDaattee (( )) ;; 
ddppttrr == nneeww DDaattee ;; 
ddppttrr -->>sseettDDaattee (( ));; 
ddppttrr..sseettDDaattee (( )) ;; WWrroonngg
PPrrootteecctteedd
DDeessttrruuccttoorr
 Allocate eennoouugghh ssppaaccee 
ffoorr 
tthhee nneeww ddaattaa 
 PPooppuullaattee tthhaatt ssppaaccee 
 DDeelleettee tthhee pprreevviioouuss 
ssppaaccee 
 PPooiinntt tthhee nneeww ssppaaccee ttoo 
tthhee
char *name =new char [[ ssttrriinngg__lleennggtthh ]]
ddeelleettee [[ ]] nnaammee
delete [[ ]] ppooiinntteerr__nnaammee
EExxaammppllee 
mmaaiinn (( )) 
{{ 
DDaattee mmyyddaattee (( ““0011--1122--22000022”” )) ;; 
mmyyddaattee..ddiissppllaayy (( )) ;; 
}}
MMeessssaaggeess
MMeetthhoodd

More Related Content

What's hot

CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30Bilal Ahmed
 
Edit data base menggunakan web
Edit data base menggunakan webEdit data base menggunakan web
Edit data base menggunakan webhaviedz miftah
 
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03Bilal Ahmed
 
Termoquímica - Setor Leste
Termoquímica - Setor LesteTermoquímica - Setor Leste
Termoquímica - Setor LesteMarianaMartinsR
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19CS201- Introduction to Programming- Lecture 19
CS201- Introduction to Programming- Lecture 19Bilal Ahmed
 

What's hot (18)

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 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
 
Edit data base menggunakan web
Edit data base menggunakan webEdit data base menggunakan web
Edit data base menggunakan web
 
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 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
 
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 13
CS201- Introduction to Programming- Lecture 13CS201- Introduction to Programming- Lecture 13
CS201- Introduction to Programming- Lecture 13
 
CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06
 
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 11
CS201- Introduction to Programming- Lecture 11CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11
 
CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14
 
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 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 
CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03CS201- Introduction to Programming- Lecture 03
CS201- Introduction to Programming- Lecture 03
 
Termoquímica - Setor Leste
Termoquímica - Setor LesteTermoquímica - Setor Leste
Termoquímica - Setor Leste
 
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 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
 

Viewers also liked

Makalah teori ukuran dan peluang
Makalah teori ukuran dan peluangMakalah teori ukuran dan peluang
Makalah teori ukuran dan peluangrukmono budi utomo
 
Didactic sequence 1 santo tomas preschool
Didactic sequence 1 santo tomas preschoolDidactic sequence 1 santo tomas preschool
Didactic sequence 1 santo tomas preschoollausansot
 
Bab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalBab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalAgung Sakepris
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
~たり、~たりします
~たり、~たりします~たり、~たりします
~たり、~たりしますAlexanderSensei
 
Diskusi masalah regulator kuadratik untuk
Diskusi masalah regulator kuadratik untukDiskusi masalah regulator kuadratik untuk
Diskusi masalah regulator kuadratik untukrukmono budi utomo
 
Bab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalBab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalAgung Sakepris
 
Week1 -lecture
Week1 -lectureWeek1 -lecture
Week1 -lecturesuncil007
 
Big Data Fundamentals
Big Data FundamentalsBig Data Fundamentals
Big Data FundamentalsSmarak Das
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTrukmono budi utomo
 
Benefits of formative eAssessment and reusable questions
Benefits of formative eAssessment and reusable questionsBenefits of formative eAssessment and reusable questions
Benefits of formative eAssessment and reusable questionsdewiparry
 

Viewers also liked (20)

Optimisasi
OptimisasiOptimisasi
Optimisasi
 
Makalah teori ukuran dan peluang
Makalah teori ukuran dan peluangMakalah teori ukuran dan peluang
Makalah teori ukuran dan peluang
 
Didactic sequence 1 santo tomas preschool
Didactic sequence 1 santo tomas preschoolDidactic sequence 1 santo tomas preschool
Didactic sequence 1 santo tomas preschool
 
Bab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personalBab2 merakit merawat dan_memperbaiki_komputer_personal
Bab2 merakit merawat dan_memperbaiki_komputer_personal
 
Web 2ggg
Web 2gggWeb 2ggg
Web 2ggg
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
~たり、~たりします
~たり、~たりします~たり、~たりします
~たり、~たりします
 
QCL-14-v3_[5S]_[SIIB]_[Sandeep Majumder]
QCL-14-v3_[5S]_[SIIB]_[Sandeep Majumder]QCL-14-v3_[5S]_[SIIB]_[Sandeep Majumder]
QCL-14-v3_[5S]_[SIIB]_[Sandeep Majumder]
 
Writing clinic itb
Writing clinic itbWriting clinic itb
Writing clinic itb
 
Diskusi masalah regulator kuadratik untuk
Diskusi masalah regulator kuadratik untukDiskusi masalah regulator kuadratik untuk
Diskusi masalah regulator kuadratik untuk
 
Bab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggalBab3 os untuk komputer_tunggal
Bab3 os untuk komputer_tunggal
 
Week1 -lecture
Week1 -lectureWeek1 -lecture
Week1 -lecture
 
3months
3months3months
3months
 
Bab9 wan
Bab9 wanBab9 wan
Bab9 wan
 
Big Data Fundamentals
Big Data FundamentalsBig Data Fundamentals
Big Data Fundamentals
 
Studi Confortiani 01: Pengantar
Studi Confortiani 01: PengantarStudi Confortiani 01: Pengantar
Studi Confortiani 01: Pengantar
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
Tugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMTTugas Metode Numerik Pendidikan Matematika UMT
Tugas Metode Numerik Pendidikan Matematika UMT
 
Benefits of formative eAssessment and reusable questions
Benefits of formative eAssessment and reusable questionsBenefits of formative eAssessment and reusable questions
Benefits of formative eAssessment and reusable questions
 
Graf presentasi
Graf presentasiGraf presentasi
Graf presentasi
 

Similar to CS201- Introduction to Programming- Lecture 28

CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 09
CS201- Introduction to Programming- Lecture 09CS201- Introduction to Programming- Lecture 09
CS201- Introduction to Programming- Lecture 09Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08Bilal Ahmed
 
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-iimaznabili
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24Bilal Ahmed
 

Similar to CS201- Introduction to Programming- Lecture 28 (16)

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 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
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 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
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 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 
CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 10CS201- Introduction to Programming- Lecture 10
CS201- Introduction to Programming- Lecture 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 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
 
ram new
ram newram new
ram new
 
CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08CS201- Introduction to Programming- Lecture 08
CS201- Introduction to Programming- Lecture 08
 
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 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
 
Tiro parabólico
Tiro parabólicoTiro parabólico
Tiro parabólico
 
Industrialisasi Media
Industrialisasi MediaIndustrialisasi Media
Industrialisasi Media
 

CS201- Introduction to Programming- Lecture 28