Suche senden
Hochladen
9781337102087 ppt ch12
•
Als PPTX, PDF herunterladen
•
0 gefällt mir
•
242 views
T
Terry Yoast
Folgen
ch 12
Weniger lesen
Mehr lesen
Bildung
Melden
Teilen
Melden
Teilen
1 von 43
Jetzt herunterladen
Empfohlen
9781337102087 ppt ch06
9781337102087 ppt ch06
Terry Yoast
Â
9781337102087 ppt ch18
9781337102087 ppt ch18
Terry Yoast
Â
9781337102087 ppt ch05
9781337102087 ppt ch05
Terry Yoast
Â
9781337102087 ppt ch08
9781337102087 ppt ch08
Terry Yoast
Â
9781337102087 ppt ch09
9781337102087 ppt ch09
Terry Yoast
Â
9781337102087 ppt ch13
9781337102087 ppt ch13
Terry Yoast
Â
9781337102087 ppt ch10
9781337102087 ppt ch10
Terry Yoast
Â
9781337102087 ppt ch14
9781337102087 ppt ch14
Terry Yoast
Â
Empfohlen
9781337102087 ppt ch06
9781337102087 ppt ch06
Terry Yoast
Â
9781337102087 ppt ch18
9781337102087 ppt ch18
Terry Yoast
Â
9781337102087 ppt ch05
9781337102087 ppt ch05
Terry Yoast
Â
9781337102087 ppt ch08
9781337102087 ppt ch08
Terry Yoast
Â
9781337102087 ppt ch09
9781337102087 ppt ch09
Terry Yoast
Â
9781337102087 ppt ch13
9781337102087 ppt ch13
Terry Yoast
Â
9781337102087 ppt ch10
9781337102087 ppt ch10
Terry Yoast
Â
9781337102087 ppt ch14
9781337102087 ppt ch14
Terry Yoast
Â
9781337102087 ppt ch17
9781337102087 ppt ch17
Terry Yoast
Â
9781337102087 ppt ch04
9781337102087 ppt ch04
Terry Yoast
Â
9781337102087 ppt ch11
9781337102087 ppt ch11
Terry Yoast
Â
Spring AOP
Spring AOP
AnushaNaidu
Â
9781337102087 ppt ch16
9781337102087 ppt ch16
Terry Yoast
Â
Spring aop concepts
Spring aop concepts
RushiBShah
Â
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Rohit Radhakrishnan
Â
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
Rohit Radhakrishnan
Â
Certification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptx
Rohit Radhakrishnan
Â
Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
IndicThreads
Â
L05 Frameworks
L05 Frameworks
Ă“lafur Andri Ragnarsson
Â
L07 Frameworks
L07 Frameworks
Ă“lafur Andri Ragnarsson
Â
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
Â
L09 Frameworks
L09 Frameworks
Ă“lafur Andri Ragnarsson
Â
Testware Hierarchy for Test Automation
Testware Hierarchy for Test Automation
Gregory Solovey
Â
Advice weaving in AspectJ
Advice weaving in AspectJ
Sander Mak (@Sander_Mak)
Â
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
Marian Wamsiedel
Â
Software Development, Data Types, and Expressions
Software Development, Data Types, and Expressions
pullaravikumar
Â
Python Fundamentals
Python Fundamentals
pullaravikumar
Â
9781337102087 ppt ch15
9781337102087 ppt ch15
Terry Yoast
Â
Sql9e ppt ch08
Sql9e ppt ch08
Dr. Ahmed Al Zaidy
Â
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
AmitaSuri
Â
Weitere ähnliche Inhalte
Was ist angesagt?
9781337102087 ppt ch17
9781337102087 ppt ch17
Terry Yoast
Â
9781337102087 ppt ch04
9781337102087 ppt ch04
Terry Yoast
Â
9781337102087 ppt ch11
9781337102087 ppt ch11
Terry Yoast
Â
Spring AOP
Spring AOP
AnushaNaidu
Â
9781337102087 ppt ch16
9781337102087 ppt ch16
Terry Yoast
Â
Spring aop concepts
Spring aop concepts
RushiBShah
Â
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Rohit Radhakrishnan
Â
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
Rohit Radhakrishnan
Â
Certification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptx
Rohit Radhakrishnan
Â
Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
IndicThreads
Â
L05 Frameworks
L05 Frameworks
Ă“lafur Andri Ragnarsson
Â
L07 Frameworks
L07 Frameworks
Ă“lafur Andri Ragnarsson
Â
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
Â
L09 Frameworks
L09 Frameworks
Ă“lafur Andri Ragnarsson
Â
Testware Hierarchy for Test Automation
Testware Hierarchy for Test Automation
Gregory Solovey
Â
Advice weaving in AspectJ
Advice weaving in AspectJ
Sander Mak (@Sander_Mak)
Â
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
Marian Wamsiedel
Â
Was ist angesagt?
(17)
9781337102087 ppt ch17
9781337102087 ppt ch17
Â
9781337102087 ppt ch04
9781337102087 ppt ch04
Â
9781337102087 ppt ch11
9781337102087 ppt ch11
Â
Spring AOP
Spring AOP
Â
9781337102087 ppt ch16
9781337102087 ppt ch16
Â
Spring aop concepts
Spring aop concepts
Â
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Â
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
Â
Certification preparation - Error Handling and Troubleshooting recap.pptx
Certification preparation - Error Handling and Troubleshooting recap.pptx
Â
Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
Â
L05 Frameworks
L05 Frameworks
Â
L07 Frameworks
L07 Frameworks
Â
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Â
L09 Frameworks
L09 Frameworks
Â
Testware Hierarchy for Test Automation
Testware Hierarchy for Test Automation
Â
Advice weaving in AspectJ
Advice weaving in AspectJ
Â
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
Â
Ă„hnlich wie 9781337102087 ppt ch12
Software Development, Data Types, and Expressions
Software Development, Data Types, and Expressions
pullaravikumar
Â
Python Fundamentals
Python Fundamentals
pullaravikumar
Â
9781337102087 ppt ch15
9781337102087 ppt ch15
Terry Yoast
Â
Sql9e ppt ch08
Sql9e ppt ch08
Dr. Ahmed Al Zaidy
Â
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
AmitaSuri
Â
C for beginners.pdf
C for beginners.pdf
TanayKashid
Â
Excel module 1 ppt presentation
Excel module 1 ppt presentation
dgdotson
Â
Access 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentation
dgdotson
Â
Chapter 14 Business Continuity
Chapter 14 Business Continuity
Dr. Ahmed Al Zaidy
Â
Chapter 15 Risk Mitigation
Chapter 15 Risk Mitigation
Dr. Ahmed Al Zaidy
Â
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
Steve Guinan
Â
Chapter 11 Authentication and Account Management
Chapter 11 Authentication and Account Management
Dr. Ahmed Al Zaidy
Â
Whitman_Ch06.pptx
Whitman_Ch06.pptx
Siphamandla9
Â
Chapter 4 Advanced Cryptography and P K I
Chapter 4 Advanced Cryptography and P K I
Dr. Ahmed Al Zaidy
Â
Chapter 4 - Completing the Problem-Solving Process
Chapter 4 - Completing the Problem-Solving Process
mshellman
Â
Chapter 3 Basic Cryptography
Chapter 3 Basic Cryptography
Dr. Ahmed Al Zaidy
Â
9781337117562_ppt_ch01.pptxChapter 1An Overview of Compute.docx
9781337117562_ppt_ch01.pptxChapter 1An Overview of Compute.docx
sleeperharwell
Â
Excel module 2 ppt presentation
Excel module 2 ppt presentation
dgdotson
Â
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5
Steve Guinan
Â
Chapter 6Network Security Devices, Design, and Technology
Chapter 6Network Security Devices, Design, and Technology
Dr. Ahmed Al Zaidy
Â
Ă„hnlich wie 9781337102087 ppt ch12
(20)
Software Development, Data Types, and Expressions
Software Development, Data Types, and Expressions
Â
Python Fundamentals
Python Fundamentals
Â
9781337102087 ppt ch15
9781337102087 ppt ch15
Â
Sql9e ppt ch08
Sql9e ppt ch08
Â
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
Â
C for beginners.pdf
C for beginners.pdf
Â
Excel module 1 ppt presentation
Excel module 1 ppt presentation
Â
Access 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentation
Â
Chapter 14 Business Continuity
Chapter 14 Business Continuity
Â
Chapter 15 Risk Mitigation
Chapter 15 Risk Mitigation
Â
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
Â
Chapter 11 Authentication and Account Management
Chapter 11 Authentication and Account Management
Â
Whitman_Ch06.pptx
Whitman_Ch06.pptx
Â
Chapter 4 Advanced Cryptography and P K I
Chapter 4 Advanced Cryptography and P K I
Â
Chapter 4 - Completing the Problem-Solving Process
Chapter 4 - Completing the Problem-Solving Process
Â
Chapter 3 Basic Cryptography
Chapter 3 Basic Cryptography
Â
9781337117562_ppt_ch01.pptxChapter 1An Overview of Compute.docx
9781337117562_ppt_ch01.pptxChapter 1An Overview of Compute.docx
Â
Excel module 2 ppt presentation
Excel module 2 ppt presentation
Â
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5
Â
Chapter 6Network Security Devices, Design, and Technology
Chapter 6Network Security Devices, Design, and Technology
Â
Mehr von Terry Yoast
9781305078444 ppt ch12
9781305078444 ppt ch12
Terry Yoast
Â
9781305078444 ppt ch11
9781305078444 ppt ch11
Terry Yoast
Â
9781305078444 ppt ch10
9781305078444 ppt ch10
Terry Yoast
Â
9781305078444 ppt ch09
9781305078444 ppt ch09
Terry Yoast
Â
9781305078444 ppt ch08
9781305078444 ppt ch08
Terry Yoast
Â
9781305078444 ppt ch07
9781305078444 ppt ch07
Terry Yoast
Â
9781305078444 ppt ch06
9781305078444 ppt ch06
Terry Yoast
Â
9781305078444 ppt ch05
9781305078444 ppt ch05
Terry Yoast
Â
9781305078444 ppt ch04
9781305078444 ppt ch04
Terry Yoast
Â
9781305078444 ppt ch03
9781305078444 ppt ch03
Terry Yoast
Â
9781305078444 ppt ch02
9781305078444 ppt ch02
Terry Yoast
Â
9781305078444 ppt ch01
9781305078444 ppt ch01
Terry Yoast
Â
9780538745840 ppt ch10
9780538745840 ppt ch10
Terry Yoast
Â
9780538745840 ppt ch09
9780538745840 ppt ch09
Terry Yoast
Â
9780538745840 ppt ch08
9780538745840 ppt ch08
Terry Yoast
Â
9780538745840 ppt ch07
9780538745840 ppt ch07
Terry Yoast
Â
9780538745840 ppt ch06
9780538745840 ppt ch06
Terry Yoast
Â
Mehr von Terry Yoast
(17)
9781305078444 ppt ch12
9781305078444 ppt ch12
Â
9781305078444 ppt ch11
9781305078444 ppt ch11
Â
9781305078444 ppt ch10
9781305078444 ppt ch10
Â
9781305078444 ppt ch09
9781305078444 ppt ch09
Â
9781305078444 ppt ch08
9781305078444 ppt ch08
Â
9781305078444 ppt ch07
9781305078444 ppt ch07
Â
9781305078444 ppt ch06
9781305078444 ppt ch06
Â
9781305078444 ppt ch05
9781305078444 ppt ch05
Â
9781305078444 ppt ch04
9781305078444 ppt ch04
Â
9781305078444 ppt ch03
9781305078444 ppt ch03
Â
9781305078444 ppt ch02
9781305078444 ppt ch02
Â
9781305078444 ppt ch01
9781305078444 ppt ch01
Â
9780538745840 ppt ch10
9780538745840 ppt ch10
Â
9780538745840 ppt ch09
9780538745840 ppt ch09
Â
9780538745840 ppt ch08
9780538745840 ppt ch08
Â
9780538745840 ppt ch07
9780538745840 ppt ch07
Â
9780538745840 ppt ch06
9780538745840 ppt ch06
Â
KĂĽrzlich hochgeladen
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
ChelloAnnAsuncion2
Â
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Sarwono Sutikno, Dr.Eng.,CISA,CISSP,CISM,CSX-F
Â
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
Celine George
Â
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
Conquiztadors- the Quiz Society of Sri Venkateswara College
Â
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
Celine George
Â
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Carlos105
Â
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Celine George
Â
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Â
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
Celine George
Â
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
Anupkumar Sharma
Â
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
Conquiztadors- the Quiz Society of Sri Venkateswara College
Â
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
Celine George
Â
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
Jisc
Â
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
KayeClaireEstoconing
Â
Full Stack Web Development Course for Beginners
Full Stack Web Development Course for Beginners
Sabitha Banu
Â
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
Dr.Ibrahim Hassaan
Â
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
mary850239
Â
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
Conquiztadors- the Quiz Society of Sri Venkateswara College
Â
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
nelietumpap1
Â
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
navabharathschool99
Â
KĂĽrzlich hochgeladen
(20)
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Â
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Â
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
Â
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
Â
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
Â
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Â
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Â
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
Â
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
Â
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
Â
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
Â
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
Â
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
Â
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
Â
Full Stack Web Development Course for Beginners
Full Stack Web Development Course for Beginners
Â
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
Â
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
Â
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
Â
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
Â
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
Â
9781337102087 ppt ch12
1.
1 C++ Programming: From
Problem Analysis to Program Design, Eighth Edition Chapter 12 Pointers, Classes, Virtual Functions, and Abstract Classes
2.
2 Objectives (1 of
3) • In this chapter, you will: • Learn about the pointer data type and pointer variables • Explore how to declare and manipulate pointer variables • Learn about the address of the operator and the dereferencing operator • Learn how pointers work with classes and structs • Discover dynamic variables © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
3.
3 Objectives (2 of
3) • Explore how to use the new and delete operators to manipulate dynamic variables • Learn about pointer arithmetic • Learn how to work with dynamic arrays • Become familiar with the limitations of range-based for loops with dynamic arrays • Explore how pointers work with functions as parameters and functions as return values © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
4.
4 Objectives (3 of
3) • Become familiar with the shallow and deep copies of data • Discover the peculiarities of classes with pointer member variables • Learn about virtual functions • Become aware of abstract classes • Examine the relationship between the address of operator and classes © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
5.
5 Pointer Data Type
and Pointer Variables • A pointer variable is a variable whose content is a memory address • No name is associated with the pointer data type in C++ © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
6.
6 Declaring Pointer Variables
(1 of 2) • The general syntax to declare a pointer variable is: • The statements below each declare a pointer: • int *p; • char *ch; • These statements are equivalent: • int *p; • int* p; • int * p; © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
7.
7 Declaring Pointer Variables
(2 of 2) • In the statement: int* p, q; • Only p is a pointer variable • q is an int variable • To avoid confusion, attach the character * to the variable name: int *p, q; int *p, *q; © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
8.
8 Address of Operator
(&) • Address of operator (&): • A unary operator that returns the address of its operand • Example: int x; int *p; p = &x; //Assigns the address of x to p © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
9.
9 Dereferencing Operator (*) •
Dereferencing operator (or indirection operator): • When used as a unary operator, * refers to object to which its operand points • Example: cout << *p << endl; • Prints the value stored in the memory location pointed to by p © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
10.
10 Classes, structs, and
Pointer Variables (1 of 3) • You can declare pointers to other data types, such as a struct: struct studentType { char name[26]; double gpa; int sID; char grade; }; studentType student; studentType* studentPtr; • student is an object of type studentType • studentPtr is a pointer variable of type studentType © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
11.
11 Classes, structs, and
Pointer Variables (2 of 3) • To store address of student in studentPtr: studentPtr = &student; • To store 3.9 in component gpa of student: (*studentPtr).gpa = 3.9; • ( ) used because dot operator has higher precedence than dereferencing operator • Alternative: use member access operator arrow (->) © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
12.
12 Classes, structs, and
Pointer Variables (3 of 3) • Syntax to access a class (struct) member using the operator -> : • Thus, (*studentPtr).gpa = 3.9; is equivalent to: studentPtr->gpa = 3.9; © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
13.
13 Initializing Pointer Variables •
C++ does not automatically initialize variables • Pointer variables must be initialized if you do not want them to point to anything • Initialized to the value 0 using the null pointer • Or, use the NULL named constant • The number 0 is the only number that can be directly assigned to a pointer variable • C++11 Standard includes a nullptr © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
14.
14 Dynamic Variables • Dynamic
variables are created during execution • C++ creates dynamic variables using pointers • new and delete operators: used to create and destroy dynamic variables • new and delete are reserved words in C++ © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
15.
15 Operator new (1
of 2) • new has two forms: • intExp is any expression evaluating to a positive integer • new allocates memory (a variable) of the designated type and returns a pointer to it • The allocated memory is uninitialized © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
16.
16 Operator new (2
of 2) • Example: p = new int; • Creates a variable during program execution somewhere in memory • Stores the address of the allocated memory in p • To access allocated memory, use *p • A dynamic variable cannot be accessed directly • Because it is unnamed © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
17.
17 Operator delete • Memory
leak: previously allocated memory that cannot be reallocated • To avoid a memory leak, when a dynamic variable is no longer needed, destroy it to deallocate its memory • delete operator: used to destroy dynamic variables • Syntax: © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
18.
18 Operations on Pointer
Variables (1 of 2) • Assignment: value of one pointer variable can be assigned to another pointer of same type • Relational operations: two pointer variables of same type can be compared for equality, etc. • Some limited arithmetic operations • Integer values can be added and subtracted from a pointer variable • Value of one pointer variable can be subtracted from another pointer variable © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
19.
19 Operations on Pointer
Variables (2 of 2) • Pointer arithmetic can be very dangerous: • Program can accidentally access memory locations of other variables and change their content without warning - Some systems might terminate the program with an appropriate error message • Always exercise extra care when doing pointer arithmetic © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
20.
20 Dynamic Arrays (1
of 2) • Dynamic array: array created during program execution • Example: int *p; p = new int[10]; *p = 25; //stores 25 in the first memory location p++; //to point to next array component *p = 35; // stores 35 into the second memory location © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
21.
21 Dynamic Arrays (2
of 2) • Can use array notation to access these memory locations • Example: p[0] = 25; p[1] = 35; • Stores 25 and 35 into the first and second array components, respectively • An array name is a constant pointer © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
22.
22 Functions and Pointers •
Pointer variable can be passed as a parameter either by value or by reference • As a reference parameter in a function heading, use &: void pointerParameters(int* &p, double *q) { . . . } © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
23.
23 Pointers and Function
Return Values • A function can return a value of type pointer: int* testExp(...) { . . . } © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
24.
24 Dynamic Two-Dimensional Arrays •
You can create dynamic multidimensional arrays • Examples: int *board[4]; //declares board to be an array of four //pointers wherein each pointer is of type for (int row = 0; row < 4; row++) board[row] = new int[6]; //creates the rows of board int **board; //declares board to be a pointer to a pointer © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
25.
25 Shallow versus Deep
Copy and Pointers • Shallow copy: when two or more pointers of the same types point to the same memory • They point to the same data • Danger: deleting one deletes the data pointed to by all of them • Deep copy: when the contents of the memory pointed to by a pointer are copied to the memory location of another pointer • Two copies of the data © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
26.
26 Classes and Pointers:
Some Peculiarities (1 of 2) • Example class: class ptrMemberVarType { public: . . . private: int x; int lenP; int *p; }; • Example program statements: ptrMemberVarType objectOne; ptrMemberVarType objectTwo; © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
27.
27 Classes and Pointers:
Some Peculiarities (2 of 2) FIGURE 12-13 Objects objectOne and objectTwo © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
28.
28 Destructor • If objectOne
goes out of scope, its member variables are destroyed • Memory space of a dynamic array stays marked as allocated, even though it cannot be accessed • Solution: in destructor, ensure that when objectOne goes out of scope, its array memory is deallocated: ptrMemberVarType::~ptrMemberVarType() { delete [] p; } © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
29.
29 Assignment Operator • After
a shallow copy: if objectTwo.p deallocates memory space to which it points, objectOne.p becomes invalid FIGURE 12-15 Objects objectOne and objectTwo • Solution: extend definition of the assignment operator to avoid shallow copying of data © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
30.
30 Copy Constructor (1
of 3) • Default member-wise initialization: • Initializing a class object by using the value of an existing object of the same type • Example: ptrMemberVarType objectThree(objectOne); • Copy constructor: provided by the compiler • Performs this initialization • Leads to a shallow copying of the data if class has pointer member variables © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
31.
31 Copy Constructor (2
of 3) • Similar problem occurs when passing objects by value • Copy constructor automatically executes in three situations: • When an object is declared and initialized by using the value of another object • When an object is passed by value as a parameter • When the return value of a function is an object © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
32.
32 Copy Constructor (3
of 3) • Solution: override the copy constructor • For classes with pointer member variables, three things are normally done: • Include the destructor in the class • Overload the assignment operator for the class • Include the copy constructor © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
33.
33 Inheritance, Pointers, and
Virtual Functions (1 of 3) • Can pass an object of a derived class to a formal parameter of the base class type • Compile-time binding: the necessary code to call specific function is generated by compiler • Also known as static binding or early binding • Virtual function: binding occurs at program execution time, not at compile time • Declared with reserved word virtual © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
34.
34 Inheritance, Pointers, and
Virtual Functions (2 of 3) • Run-time binding: • Compiler does not generate code to call a specific function: it generates information to enable run-time system to generate specific code for the function call • Also known as late binding or dynamic binding • Note: cannot pass an object of base class type to a formal parameter of the derived class type © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
35.
35 Inheritance, Pointers, and
Virtual Functions (3 of 3) • Values of a derived class object can be copied into a base class object • Slicing problem: if derived class has more data members than base class, some data could be lost • Solution: use pointers for both base and derived class objects © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
36.
36 Classes and Virtual
Destructors (1 of 2) • Classes with pointer member variables should have the destructor • Destructor should deallocate storage for dynamic objects • If a derived class object is passed to a formal parameter of the base class type, destructor of the base class executes • Regardless of whether object is passed by reference or by value • Solution: use a virtual destructor (base class) © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
37.
37 Classes and Virtual
Destructors (2 of 2) • Virtual destructor of a base class automatically makes the destructor of a derived class virtual • After executing the destructor of the derived class, the destructor of the base class executes • If a base class contains virtual functions, make the destructor of the base class virtual © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
38.
38 Abstract Classes and
Pure Virtual Functions (1 of 2) • New classes can be derived through inheritance without designing them from scratch • Derived classes: • Inherit existing members of base class • Can add their own members • Can redefine or override public and protected member functions • Base class can contain functions that you would want each derived class to implement • However, base class may contain functions that may not have meaningful definitions in the base class © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
39.
39 Abstract Classes and
Pure Virtual Functions (2 of 2) • Pure virtual functions do not have definitions (bodies have no code) • Example: virtual void draw() = 0; • An abstract class is a class with one or more virtual functions • It can contain instance variables, constructors, and functions that are not pure virtual • It must provide the definitions of the constructor and functions that are not pure virtual © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
40.
40 Address of Operator
and Classes (1 of 2) • & operator can create aliases to an object • Example: int x; int &y = x; //x and y refer to the same memory location //y is like a constant pointer variable y = 25; //sets the value of y (and of x) to 25 x = 2 * x + 30; //updates value of x and y © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
41.
41 Address of Operator
and Classes (2 of 2) • Address of operator can also be used to return the address of a private member variable of a class • However, if you are not careful, this operation can result in serious errors in the program © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
42.
42 Quick Review (1
of 2) • Pointer variables contain the addresses of other variables as their values • Declare a pointer variable with an asterisk, *, between the data type and the variable • Address of operator (&) returns the address of its operand • Unary operator * is the dereferencing operator • Member access operator (->) accesses the object component pointed to by a pointer © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
43.
43 Quick Review (2
of 2) • Dynamic variable: created during execution • Created using new • Deallocated using delete • Shallow copy: two or more pointers of the same type point to the same memory • Deep copy: two or more pointers of the same type have their own copies of the data • Binding of virtual functions occurs at execution time (dynamic or run-time binding) © 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom
Jetzt herunterladen