Karteikarten
COMP 206 Unit 5: Hiding the Implementation
Karten in diesem Stapel (13)
- 1Reasons to control access to structure members1. keep client programmer away from tools that are necessary for internal machinations of data types
2. allow library designer to change internal workings of structure without affecting client programmer - 2access specifierschange boundary for all declarations that follow them
- 3publicall member declarations that follow are available to everyone
- 4private-no on can access member except creator of type
-only functions clearly stated in structure declaration can have access to private members - 5protected-acts like private
-inherited structures are granted access to protected members - 6friend-explicitly grants to function that isn't member of current structure
-declared inside structure declaration
-can access private, protected, and public member of class - 7nested friends1. declare nested structure
2. declare structure as friend
3. define structure - 8C Struct- cannot have member functions inside structures
- cannot initialize data directly
- write 'struct' to declare variables
- cannot have static members
-sizeof generates 0 for empty structure
- data hiding feature not available
- does not have access modifiers - 9C++ Struct- hold member functions with member variables
- directly initialize data in C++
- do not need 'struct' for declaring variables
- can have static members
-sizeof generates 1 for empty structure
- data hiding features is present
- have access specifiers - 10Use of class- class used to describe new data type
- any object belonging to class will share characteristics and behaviors - 11C++ class vs C struct1. C struct has no access specifiers; C++ class defaults to private
2. C struct does not support inheritance; C++ class supports inheritance - 12C++ class vs C++ struct1. C++ class defaults to private; C++ struct defaults to public
2. default inheritance behavior is private for classes but public for struct - 13Implementation Hidinghave actual structure compiled inside implementation file rather than exposed in header file
Informationen
- Beschreibung
- University-level C++ COMP 206 Karteikarten am COMP 206 Unit 5: Hiding the Implementation, erstellt von Adriana Vincelli-Joma am 10/09/2021.
- Erstellt von
- Adriana Vincelli-Joma
- Aufrufe
- 16
- Tags
- Bewertung