Criado por Adriana Vincelli-Joma
aproximadamente 3 anos atrás
|
||
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 |
Quer criar seus próprios Flashcards gratuitos com GoConqr? Saiba mais.