Enviar búsqueda
Cargar
C++ Chapter 11 OOP - Part 2
•
Descargar como PPTX, PDF
•
0 recomendaciones
•
55 vistas
D
DanWooster1
Seguir
C++
Leer menos
Leer más
Educación
Denunciar
Compartir
Denunciar
Compartir
1 de 21
Descargar ahora
Recomendados
Common Programming Errors by Beginners in Java
Common Programming Errors by Beginners in Java
Ravi_Kant_Sahu
Packages
Packages
Ravi Kant Sahu
java interface and packages
java interface and packages
VINOTH R
Methods and constructors
Methods and constructors
Ravi_Kant_Sahu
Java access modifiers
Java access modifiers
Srinivas Reddy
Inheritance
Inheritance
Ravi_Kant_Sahu
Java access modifiers
Java access modifiers
Khaled Adnan
Interfaces In Java
Interfaces In Java
parag
Recomendados
Common Programming Errors by Beginners in Java
Common Programming Errors by Beginners in Java
Ravi_Kant_Sahu
Packages
Packages
Ravi Kant Sahu
java interface and packages
java interface and packages
VINOTH R
Methods and constructors
Methods and constructors
Ravi_Kant_Sahu
Java access modifiers
Java access modifiers
Srinivas Reddy
Inheritance
Inheritance
Ravi_Kant_Sahu
Java access modifiers
Java access modifiers
Khaled Adnan
Interfaces In Java
Interfaces In Java
parag
Java interface
Java interface
Arati Gadgil
packages and interfaces
packages and interfaces
madhavi patil
C# classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented concepts
Vaibhav Khanna
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
Class Diagram | OOP and Design Patterns by Oum Saokosal
Class Diagram | OOP and Design Patterns by Oum Saokosal
OUM SAOKOSAL
Interface
Interface
kamal kotecha
Data classes in kotlin by Naveed
Data classes in kotlin by Naveed
Naveed Ahmad - Google Certified Android Developer ✪
Packages and Interfaces
Packages and Interfaces
AkashDas112
Java Chapter 04 - Writing Classes: part 2
Java Chapter 04 - Writing Classes: part 2
DanWooster1
Core java notes with examples
Core java notes with examples
bindur87
Keywords and classes
Keywords and classes
Ravi_Kant_Sahu
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Venugopalavarma Raja
Packages and interfaces
Packages and interfaces
bhuvaneshwariA5
Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
Mi0041 java and web design
Mi0041 java and web design
Study Stuff
Java non access modifiers
Java non access modifiers
Srinivas Reddy
Access modifiers
Access modifiers
Kasun Ranga Wijeweera
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
Uzair Salman
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 7
DanWooster1
C++ Chapter 11 OOP - Part 5
C++ Chapter 11 OOP - Part 5
DanWooster1
Más contenido relacionado
La actualidad más candente
Java interface
Java interface
Arati Gadgil
packages and interfaces
packages and interfaces
madhavi patil
C# classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented concepts
Vaibhav Khanna
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
Class Diagram | OOP and Design Patterns by Oum Saokosal
Class Diagram | OOP and Design Patterns by Oum Saokosal
OUM SAOKOSAL
Interface
Interface
kamal kotecha
Data classes in kotlin by Naveed
Data classes in kotlin by Naveed
Naveed Ahmad - Google Certified Android Developer ✪
Packages and Interfaces
Packages and Interfaces
AkashDas112
Java Chapter 04 - Writing Classes: part 2
Java Chapter 04 - Writing Classes: part 2
DanWooster1
Core java notes with examples
Core java notes with examples
bindur87
Keywords and classes
Keywords and classes
Ravi_Kant_Sahu
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Venugopalavarma Raja
Packages and interfaces
Packages and interfaces
bhuvaneshwariA5
Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
Mi0041 java and web design
Mi0041 java and web design
Study Stuff
Java non access modifiers
Java non access modifiers
Srinivas Reddy
Access modifiers
Access modifiers
Kasun Ranga Wijeweera
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
Uzair Salman
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
La actualidad más candente
(20)
Java interface
Java interface
packages and interfaces
packages and interfaces
C# classes objects
C# classes objects
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented concepts
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
Class Diagram | OOP and Design Patterns by Oum Saokosal
Class Diagram | OOP and Design Patterns by Oum Saokosal
Interface
Interface
Data classes in kotlin by Naveed
Data classes in kotlin by Naveed
Packages and Interfaces
Packages and Interfaces
Java Chapter 04 - Writing Classes: part 2
Java Chapter 04 - Writing Classes: part 2
Core java notes with examples
Core java notes with examples
Keywords and classes
Keywords and classes
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Packages and interfaces
Packages and interfaces
Object Oriented Programming Using C++
Object Oriented Programming Using C++
Mi0041 java and web design
Mi0041 java and web design
Java non access modifiers
Java non access modifiers
Access modifiers
Access modifiers
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
Similar a C++ Chapter 11 OOP - Part 2
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 7
DanWooster1
C++ Chapter 11 OOP - Part 5
C++ Chapter 11 OOP - Part 5
DanWooster1
C++ Chapter 11 OOP - Part 6
C++ Chapter 11 OOP - Part 6
DanWooster1
C++ Chapter 11 OOP - Part 3
C++ Chapter 11 OOP - Part 3
DanWooster1
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
DanWooster1
C++ Chapter 11 OOP - Part 4
C++ Chapter 11 OOP - Part 4
DanWooster1
Chapter11.ppt
Chapter11.ppt
KalyaniLokhande5
Operator overloading
Operator overloading
farhan amjad
Lecture-11 Friend Functions and inline functions.pptx
Lecture-11 Friend Functions and inline functions.pptx
rayanbabur
C++ Programming Course
C++ Programming Course
Dennis Chang
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
Getachew Ganfur
Ch7Structs.pptx
Ch7Structs.pptx
TalhaLaique1
Encapsulation
Encapsulation
FALLEE31188
Object-oriented Design: Polymorphism via Inheritance (vs. Delegation)
Object-oriented Design: Polymorphism via Inheritance (vs. Delegation)
Adair Dingle
Lecture 08-inheritance-i
Lecture 08-inheritance-i
Waleed Arshad
Inheritance, Polymorphism, and Virtual Functions.pptx
Inheritance, Polymorphism, and Virtual Functions.pptx
MrNikhilMohanShinde
Class and object
Class and object
prabhat kumar
Android coding guide lines
Android coding guide lines
lokeshG38
Intake 37 4
Intake 37 4
Mahmoud Ouf
A COMPLETE FILE FOR C++
A COMPLETE FILE FOR C++
M Hussnain Ali
Similar a C++ Chapter 11 OOP - Part 2
(20)
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 7
C++ Chapter 11 OOP - Part 5
C++ Chapter 11 OOP - Part 5
C++ Chapter 11 OOP - Part 6
C++ Chapter 11 OOP - Part 6
C++ Chapter 11 OOP - Part 3
C++ Chapter 11 OOP - Part 3
CSCI 238 Chapter 07 - Classes
CSCI 238 Chapter 07 - Classes
C++ Chapter 11 OOP - Part 4
C++ Chapter 11 OOP - Part 4
Chapter11.ppt
Chapter11.ppt
Operator overloading
Operator overloading
Lecture-11 Friend Functions and inline functions.pptx
Lecture-11 Friend Functions and inline functions.pptx
C++ Programming Course
C++ Programming Course
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
Ch7Structs.pptx
Ch7Structs.pptx
Encapsulation
Encapsulation
Object-oriented Design: Polymorphism via Inheritance (vs. Delegation)
Object-oriented Design: Polymorphism via Inheritance (vs. Delegation)
Lecture 08-inheritance-i
Lecture 08-inheritance-i
Inheritance, Polymorphism, and Virtual Functions.pptx
Inheritance, Polymorphism, and Virtual Functions.pptx
Class and object
Class and object
Android coding guide lines
Android coding guide lines
Intake 37 4
Intake 37 4
A COMPLETE FILE FOR C++
A COMPLETE FILE FOR C++
Más de DanWooster1
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile Development
DanWooster1
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
DanWooster1
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
DanWooster1
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
DanWooster1
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
DanWooster1
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
DanWooster1
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
DanWooster1
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 3
DanWooster1
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 2
DanWooster1
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 525 Data Mining Chapter 1
DanWooster1
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 8 - Arrays
DanWooster1
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
DanWooster1
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 03 Using Classes
DanWooster1
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 02 Data & Expressions
DanWooster1
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
DanWooster1
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
DanWooster1
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
DanWooster1
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
DanWooster1
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
Más de DanWooster1
(20)
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Unit testing
Upstate CSCI 540 Unit testing
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 9
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 450 WebDev Chapter 1
Upstate 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 2
Upstate 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 - Arrays
Upstate CSCI 200 Java Chapter 7 - OOP
Upstate CSCI 200 Java Chapter 7 - OOP
CSCI 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 & Expressions
CSCI 200 Java Chapter 01
CSCI 200 Java Chapter 01
CSCI 238 Chapter 08 Arrays Textbook Slides
CSCI 238 Chapter 08 Arrays Textbook Slides
Chapter 6 - More conditionals and loops
Chapter 6 - More conditionals and loops
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP Chapters 5, 12, 13
Último
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
MaritesTamaniVerdade
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Denish Jangid
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
camerronhm
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
neillewis46
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
TechSoup
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
Association for Project Management
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
callscotland1987
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
Poh-Sun Goh
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
Nguyen Thanh Tu Collection
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
Mebane Rash
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
Admir Softic
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
bronxfugly43
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
christianmathematics
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
Amanpreet Kaur
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
Nirmal Dwivedi
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
Sherif Taha
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
Esquimalt MFRC
Último
(20)
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
C++ Chapter 11 OOP - Part 2
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.1 The this Pointer and Constant Member Functions •this pointer: - Implicit parameter passed to every member function - it points to the object calling the function •const member function: - does not modify its calling object 11-3
4.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Using the this Pointer Can be used to access members that may be hidden by parameters with the same name: class SomeClass { private: int num; public: void setNum(int num) { this->num = num; } }; 11-4
5.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Constant Member Functions •Declared with keyword const •When const appears in the parameter list, int setNum (const int num) the function is prevented from modifying the parameter. The parameter is read-only. •When const follows the parameter list, int getX()const the function is prevented from modifying the object. 11-5
6.
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-6 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
7.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved KEY CONCEPT 1-7
8.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved 11.2 Static Members •Static member variable: –There is one instance of the variable for the entire class –It is shared by all objects of the class •Static member function: –Can be used to access static member variables –Can be called before any class objects are created 11-8
9.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Static Member Variables 1 of 3 1) Must be declared in the class with the keyword static: class IntVal { public: intVal(int val = 0) { value = val; valCount++ } int getVal(); void setVal(int); private: int value; static int valCount; }; 11-9
10.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Static Member Variables 2 of 3 2) Must be defined outside of the class: class IntVal { //In-class declaration static int valCount; //Other members not shown }; //Definition outside of class int IntVal::valCount = 0; 11-10
11.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Static Member Variables 3 of 3 3) Can be accessed or modified by any object of the class: Modifications by one object are visible to all objects of the class: IntVal val1, val2; 11-11
12.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Static Member Functions 1 of 2 1)Declared with static before the return type: class IntVal { public: static int getValCount() { return valCount; } private: int value; static int valCount; }; 11-12
13.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Static Member Functions 2 of 2 2) Can be called independently of any class objects, through the class name: cout << IntVal::getValCount(); 3) Because of item 2 above, the this pointer cannot be used 4) Can be called before any objects of the class have been created 5) Used primarily to manipulate static member variables of the class 11-13
14.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved KEY CONCEPT 1- 14
15.
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-15 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
16.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved KEY CONCEPT 1- 16
17.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved 11.3 Friends of Classes •Friend function: a function that is not a member of a class, but has access to private members of the class •A friend function can be a stand-alone function or a member function of another class •It is declared a friend of a class with the friend keyword in the function prototype 11-17
18.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Friend Function Declarations 1 of 2 1) Friend function may be a stand-alone function: class aClass { private: int x; friend void fSet(aClass &c, int a); }; void fSet(aClass &c, int a) { c.x = a; } 11-18
19.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Friend Function Declarations 2 of 2 2) A friend function may be a member of another class: class aClass { private: int x; friend void OtherClass::fSet (aClass &c, int a); }; class OtherClass { public: void fSet(aClass &c, int a) { c.x = a; } }; 11-19
20.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Friend Class Declaration 1 of 2 3) An entire class can be declared a friend of a class: class aClass {private: int x; friend class frClass; }; class frClass {public: void fSet(aClass &c,int a){c.x = a;} int fGet(aClass c){return c.x;} }; 11-20
21.
Copyright © 2020,
2017, 2014 Pearson Education, Inc. All Rights Reserved Friend Class Declaration 2 of 2 •If frClass is a friend of aClass, then all member functions of frClass have unrestricted access to all members of aClass, including the private members. •In general, you should restrict the property of Friendship to only those functions that must have access to the private members of a class. 11-21
Descargar ahora