SlideShare a Scribd company logo
1 of 14
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
OUTLINE
11.1 The this Pointer and
Constant Member
Functions
11.2 Static Members
11.3 Friends of Classes
11.4 Memberwise
Assignment
11.5 Copy Constructors
11.6 Operator Overloading
11.7 Rvalue References and
Move Operations
11-1
11.8 Type Conversion
Operators
11.9 Convert Constructors
11.10 Aggregation and
Composition
11.11 Inheritance
11.12 Protected Members and
Class Access
11.13 Constructors,
Destructors, and Inheritance
11.14 Overriding Base Class
Functions
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
KEY CONCEPT
1-2
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
11.10 Aggregation and Composition
•Class aggregation: An object of one class
owns an object of another class
•Class composition: A form of aggregation
where the owning class controls the lifetime of
the objects of the owned class
•Supports the modeling of ‘has-a’ relationship
between classes – owning class ‘has a(n)’
instance of the owned class
11-3
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Object Composition
class StudentInfo
{
private:
string firstName, LastName;
string address, city, state, zip;
...
};
class Student
{
private:
StudentInfo personalData;
...
};
11-4
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Member Initialization Lists 1 of 2
•Used in constructors for classes involved in
aggregation.
•Allows constructor for owning class to pass
arguments to the constructor of the owned class
•Notation:
owner_class(parameters):owned_object(parameters);
11-5
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Member Initialization Lists 2 of 2
Use:
class StudentInfo
{
...
};
class Student
{
private:
StudentInfo personalData;
public:
Student(string fname, string lname):
personalData(fname, lname){};
};
11-6
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Aggregation Through Pointers
•A ‘has-a’ relationship can be implemented by
owning a pointer to an object
•This can be used when multiple objects of a class
may ‘have’ the same attribute for a member
–ex: students who may have the same city/state/
zipcode
•Using pointers minimizes data duplication and
saves space
11-7
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Aggregation, Composition, and Object
Lifetimes
•Aggregation represents the owner/owned
relationship between objects.
•Composition is a form of aggregation in which the
lifetime of the owned object is the same as that of
the owner object
•The owned object is usually created as part of the
owning object’s constructor, and destroyed as part
of owning object’s destructor
11-8
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
OUTLINE
11.1 The this Pointer and
Constant Member
Functions
11.2 Static Members
11.3 Friends of Classes
11.4 Memberwise
Assignment
11.5 Copy Constructors
11.6 Operator Overloading
11.7 Rvalue References and
Move Operations
11-9
11.8 Type Conversion
Operators
11.9 Convert Constructors
11.10 Aggregation and
Composition
11.11 Inheritance
11.12 Protected Members and
Class Access
11.13 Constructors,
Destructors, and Inheritance
11.14 Overriding Base Class
Functions
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
11.11 Inheritance
•Inheritance is a way of creating a new class by
starting with an existing class and adding new
members
•The new class can replace or extend the
functionality of the existing class
•Inheritance models the 'is-a' relationship between
classes
11-10
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Inheritance - Terminology
•The existing class is called the base class
–Alternates: parent class, superclass
•The new class is called the derived class
–Alternates: child class, subclass
11-11
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Inheritance Syntax and Notation
// Existing class
class Base
{
};
// Derived class
class Derived : public Base
{
};
Inheritance Class
Diagram
11-12
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Inheritance of Members
class Parent
{
int a;
void bf();
};
class Child : public
Parent
{
int c;
void df();
};
Objects of Parent have
members
int a; void bf();
Objects of Child have
members
int a; void bf();
int c; void df();
Access specifiers will
determine availability
11-13
Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved
Dynamic Allocation of Objects
•When dealing with inheritance, objects should be
created using dynamic memory and accessed via
pointers to the allocated memory.
•A method that expects an argument of a base class
may not have the space needed to accept an
argument of a derived class, even though an object
of a derived class “is-a” object of the base class.
•Use pointers to objects instead of objects for
parameter list and arguments.
11-14

More Related Content

Similar to C++ Chapter 11 OOP - Part 6

CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - ClassesCSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - ClassesDanWooster1
 
Five D2L Tools to Increase Student Engagement and Instructor Presence
Five D2L Tools to Increase Student Engagement and Instructor PresenceFive D2L Tools to Increase Student Engagement and Instructor Presence
Five D2L Tools to Increase Student Engagement and Instructor PresenceD2L Barry
 
Repositories and the wider context
Repositories and the wider contextRepositories and the wider context
Repositories and the wider contextJulie Allinson
 
Microservices Primer for Monolithic Devs
Microservices Primer for Monolithic DevsMicroservices Primer for Monolithic Devs
Microservices Primer for Monolithic DevsLloyd Faulkner
 
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOPUpstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOPDanWooster1
 
Chapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptChapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptPatrick Okot
 
7) Using Brightspace Tools to Increase Student Engagement and Instructor Pres...
7)	Using Brightspace Tools to Increase Student Engagement and Instructor Pres...7)	Using Brightspace Tools to Increase Student Engagement and Instructor Pres...
7) Using Brightspace Tools to Increase Student Engagement and Instructor Pres...D2L Barry
 
Lecture 08-inheritance-i
Lecture 08-inheritance-iLecture 08-inheritance-i
Lecture 08-inheritance-iWaleed Arshad
 
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearning
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearningImplementing Blended Learning Workshop #ISTE2015 #BlendedLearning
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearningRob Darrow
 
Sitkoski Metadata Proposal - Final
Sitkoski Metadata Proposal - FinalSitkoski Metadata Proposal - Final
Sitkoski Metadata Proposal - FinalKeith Sitkoski
 
Publishing and Education Service on the Open Web Platform
Publishing and Education Service on the Open Web PlatformPublishing and Education Service on the Open Web Platform
Publishing and Education Service on the Open Web PlatformOpen Cyber University of Korea
 
Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Training Industry Conference & Expo
 
The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...Julie Allinson
 
Directions This assignment is for a Reading Course. The cross-dis
Directions This assignment is for a Reading Course. The cross-disDirections This assignment is for a Reading Course. The cross-dis
Directions This assignment is for a Reading Course. The cross-disAlyciaGold776
 

Similar to C++ Chapter 11 OOP - Part 6 (20)

CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - ClassesCSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
 
Ch 7 pp7
Ch 7 pp7Ch 7 pp7
Ch 7 pp7
 
Calet
CaletCalet
Calet
 
Five D2L Tools to Increase Student Engagement and Instructor Presence
Five D2L Tools to Increase Student Engagement and Instructor PresenceFive D2L Tools to Increase Student Engagement and Instructor Presence
Five D2L Tools to Increase Student Engagement and Instructor Presence
 
Repositories and the wider context
Repositories and the wider contextRepositories and the wider context
Repositories and the wider context
 
An Overview of Entity Framework
An Overview of Entity FrameworkAn Overview of Entity Framework
An Overview of Entity Framework
 
Microservices Primer for Monolithic Devs
Microservices Primer for Monolithic DevsMicroservices Primer for Monolithic Devs
Microservices Primer for Monolithic Devs
 
Linked Data Competency Index : Mapping the field for teachers and learners
 Linked Data Competency Index : Mapping the field for teachers and learners Linked Data Competency Index : Mapping the field for teachers and learners
Linked Data Competency Index : Mapping the field for teachers and learners
 
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOPUpstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
 
Chapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptChapter08 - Inheritance.ppt
Chapter08 - Inheritance.ppt
 
7) Using Brightspace Tools to Increase Student Engagement and Instructor Pres...
7)	Using Brightspace Tools to Increase Student Engagement and Instructor Pres...7)	Using Brightspace Tools to Increase Student Engagement and Instructor Pres...
7) Using Brightspace Tools to Increase Student Engagement and Instructor Pres...
 
Lecture 08-inheritance-i
Lecture 08-inheritance-iLecture 08-inheritance-i
Lecture 08-inheritance-i
 
EDUPUB Tokyo 2014 day2 Paul Belfanti and Markus Gylling
EDUPUB Tokyo 2014 day2 Paul Belfanti and Markus GyllingEDUPUB Tokyo 2014 day2 Paul Belfanti and Markus Gylling
EDUPUB Tokyo 2014 day2 Paul Belfanti and Markus Gylling
 
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearning
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearningImplementing Blended Learning Workshop #ISTE2015 #BlendedLearning
Implementing Blended Learning Workshop #ISTE2015 #BlendedLearning
 
Ch 8 pp8
Ch 8 pp8Ch 8 pp8
Ch 8 pp8
 
Sitkoski Metadata Proposal - Final
Sitkoski Metadata Proposal - FinalSitkoski Metadata Proposal - Final
Sitkoski Metadata Proposal - Final
 
Publishing and Education Service on the Open Web Platform
Publishing and Education Service on the Open Web PlatformPublishing and Education Service on the Open Web Platform
Publishing and Education Service on the Open Web Platform
 
Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...
 
The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...
 
Directions This assignment is for a Reading Course. The cross-dis
Directions This assignment is for a Reading Course. The cross-disDirections This assignment is for a Reading Course. The cross-dis
Directions This assignment is for a Reading Course. The cross-dis
 

More from DanWooster1

Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile DevelopmentUpstate CSCI 540 Agile Development
Upstate CSCI 540 Agile DevelopmentDanWooster1
 
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingUpstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingDanWooster1
 
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4DanWooster1
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4DanWooster1
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3DanWooster1
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2DanWooster1
 
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2DanWooster1
 
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1DanWooster1
 
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - ArraysUpstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - ArraysDanWooster1
 
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using ClassesCSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using ClassesDanWooster1
 
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & ExpressionsCSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & ExpressionsDanWooster1
 
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01DanWooster1
 
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook SlidesCSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook SlidesDanWooster1
 
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loopsChapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loopsDanWooster1
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQueryDanWooster1
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13DanWooster1
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHPDanWooster1
 

More from DanWooster1 (20)

Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile DevelopmentUpstate CSCI 540 Agile Development
Upstate CSCI 540 Agile Development
 
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testingUpstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
 
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
 
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
 
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
 
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
 
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
 
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
 
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - ArraysUpstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - Arrays
 
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using ClassesCSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
 
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & ExpressionsCSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
 
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
 
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook SlidesCSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
 
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loopsChapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
 
Upstate CSCI 450 PHP
Upstate CSCI 450 PHPUpstate CSCI 450 PHP
Upstate CSCI 450 PHP
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 

C++ Chapter 11 OOP - Part 6

  • 1. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved OUTLINE 11.1 The this Pointer and Constant Member Functions 11.2 Static Members 11.3 Friends of Classes 11.4 Memberwise Assignment 11.5 Copy Constructors 11.6 Operator Overloading 11.7 Rvalue References and Move Operations 11-1 11.8 Type Conversion Operators 11.9 Convert Constructors 11.10 Aggregation and Composition 11.11 Inheritance 11.12 Protected Members and Class Access 11.13 Constructors, Destructors, and Inheritance 11.14 Overriding Base Class Functions
  • 2. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved KEY CONCEPT 1-2
  • 3. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved 11.10 Aggregation and Composition •Class aggregation: An object of one class owns an object of another class •Class composition: A form of aggregation where the owning class controls the lifetime of the objects of the owned class •Supports the modeling of ‘has-a’ relationship between classes – owning class ‘has a(n)’ instance of the owned class 11-3
  • 4. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Object Composition class StudentInfo { private: string firstName, LastName; string address, city, state, zip; ... }; class Student { private: StudentInfo personalData; ... }; 11-4
  • 5. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Member Initialization Lists 1 of 2 •Used in constructors for classes involved in aggregation. •Allows constructor for owning class to pass arguments to the constructor of the owned class •Notation: owner_class(parameters):owned_object(parameters); 11-5
  • 6. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Member Initialization Lists 2 of 2 Use: class StudentInfo { ... }; class Student { private: StudentInfo personalData; public: Student(string fname, string lname): personalData(fname, lname){}; }; 11-6
  • 7. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Aggregation Through Pointers •A ‘has-a’ relationship can be implemented by owning a pointer to an object •This can be used when multiple objects of a class may ‘have’ the same attribute for a member –ex: students who may have the same city/state/ zipcode •Using pointers minimizes data duplication and saves space 11-7
  • 8. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Aggregation, Composition, and Object Lifetimes •Aggregation represents the owner/owned relationship between objects. •Composition is a form of aggregation in which the lifetime of the owned object is the same as that of the owner object •The owned object is usually created as part of the owning object’s constructor, and destroyed as part of owning object’s destructor 11-8
  • 9. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved OUTLINE 11.1 The this Pointer and Constant Member Functions 11.2 Static Members 11.3 Friends of Classes 11.4 Memberwise Assignment 11.5 Copy Constructors 11.6 Operator Overloading 11.7 Rvalue References and Move Operations 11-9 11.8 Type Conversion Operators 11.9 Convert Constructors 11.10 Aggregation and Composition 11.11 Inheritance 11.12 Protected Members and Class Access 11.13 Constructors, Destructors, and Inheritance 11.14 Overriding Base Class Functions
  • 10. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved 11.11 Inheritance •Inheritance is a way of creating a new class by starting with an existing class and adding new members •The new class can replace or extend the functionality of the existing class •Inheritance models the 'is-a' relationship between classes 11-10
  • 11. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Inheritance - Terminology •The existing class is called the base class –Alternates: parent class, superclass •The new class is called the derived class –Alternates: child class, subclass 11-11
  • 12. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Inheritance Syntax and Notation // Existing class class Base { }; // Derived class class Derived : public Base { }; Inheritance Class Diagram 11-12
  • 13. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Inheritance of Members class Parent { int a; void bf(); }; class Child : public Parent { int c; void df(); }; Objects of Parent have members int a; void bf(); Objects of Child have members int a; void bf(); int c; void df(); Access specifiers will determine availability 11-13
  • 14. Copyright © 2020, 2017, 2014 Pearson Education, Inc. All Rights Reserved Dynamic Allocation of Objects •When dealing with inheritance, objects should be created using dynamic memory and accessed via pointers to the allocated memory. •A method that expects an argument of a base class may not have the space needed to accept an argument of a derived class, even though an object of a derived class “is-a” object of the base class. •Use pointers to objects instead of objects for parameter list and arguments. 11-14