COMP 206 Unit 5: Hiding the Implementation

Descrição

University-level C++ COMP 206 FlashCards sobre COMP 206 Unit 5: Hiding the Implementation, criado por Adriana Vincelli-Joma em 10-09-2021.
Adriana Vincelli-Joma
FlashCards por Adriana Vincelli-Joma, atualizado more than 1 year ago
Adriana Vincelli-Joma
Criado por Adriana Vincelli-Joma aproximadamente 3 anos atrás
2
0

Resumo de Recurso

Questão Responda
Reasons to control access to structure members 1. 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
access specifiers change boundary for all declarations that follow them
public all member declarations that follow are available to everyone
private -no on can access member except creator of type -only functions clearly stated in structure declaration can have access to private members
protected -acts like private -inherited structures are granted access to protected members
friend -explicitly grants to function that isn't member of current structure -declared inside structure declaration -can access private, protected, and public member of class
nested friends 1. declare nested structure 2. declare structure as friend 3. define structure
C 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
C++ 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
Use of class - class used to describe new data type - any object belonging to class will share characteristics and behaviors
C++ class vs C struct 1. C struct has no access specifiers; C++ class defaults to private 2. C struct does not support inheritance; C++ class supports inheritance
C++ class vs C++ struct 1. C++ class defaults to private; C++ struct defaults to public 2. default inheritance behavior is private for classes but public for struct
Implementation Hiding have actual structure compiled inside implementation file rather than exposed in header file

Semelhante

COMP 206 Unit 6: Initialization and Cleanup
Adriana Vincelli-Joma
COMP 206 Unit 7: Function Overloading and Default Arguments
Adriana Vincelli-Joma
COMP 206 Unit 8: Constants
Adriana Vincelli-Joma
COMP 206 Unit 9: Name Control
Adriana Vincelli-Joma
COMP 206 Unit 11: Operator Overloading
Adriana Vincelli-Joma
COMP 206 Unit 12: Dynamic Object Creation
Adriana Vincelli-Joma
COMP 206 Unit 13: Inheritance and Composition
Adriana Vincelli-Joma
COMP 206 Unit 3: The C in C++
Adriana Vincelli-Joma
GOVN 377 Unit 8: The Brave New World of Data Management and Manipulation
Adriana Vincelli-Joma
GOVN 377 Unit 6: New Technology: Data Mining, Matching, and Management
Adriana Vincelli-Joma
GOVN 377 Unit 7: Research and the Implications for Information Access adn Privacy
Adriana Vincelli-Joma