Week 1 Flashcards
Objects are instances of _______
classes
Object-oriented languages offer three high-level features for programming solutions:
encapsulation
inheritance
polymorphism
fundamental types:
correspond directly to the. hardware facilities
built-in types:
reflect the capabilities of the hardware facilities directly and efficiently
User-defined types
concrete types:
abstract types:
concrete types - their representation is part of their definition and is known
abstract types - their representation is not part of their definition and is unknown
declaration:
A declaration introduces a name into a program and associates that name with a type.
ex.
int x;
void display();
4 types of scopes:
local scope - the name has been declared within a function or code block
class scope - the name has been declared as a member of a class
namespace scope - the name has been declared as a member of a named block
global scope - the name has not been declared in any one of the above scopes
linkage:
A name has a linkage if it can refer to an identical name declared in another scope. Linkage is optional.
The linkage of a name may be
external - connected across different scopes in different modules
internal - connected across different scopes within the same module
non-existent - not connected to any entity outside its own scope
memory distinctions:
code segment - stores the program instructions
data segments - store data that survives the lifetime of the program
stack segment - stores local data that is, statically allocated
heap segment - stores local data that is dynamically allocated
definition:
A definition is a declaration that associates a meaning with a name. A declaration may be a definition but is not necessarily a definition.
one-definition rule:
A definition may not appear more than once across all translation units. No translation unit may contain more than one definition of a variable, function, class or template. If a definition appears in multiple translation units, that definition must be identical in all translation units in which it appears.
scope:
The scope is the region of the program throughout which the name is valid; that is, the region where the entity identified by that name is visible.
initializer expressions:
The scope of a name declared in the selection condition of a selection construct extends to the end of the construct itself.
ex.
if (int j = i % 10; j < 5) {
i -= j;
access a shadowed global variable with the name ‘x’:
use the scope resolution operator:
::x
external linkage:
A name with external linkage refers to an entity that is declared in a different scope within another translation unit. The C++ keyword extern identifies external linkage.
ex.
extern int share_me; // declaration
We omit this linkage keyword in the translation unit that defines and initialize the named entity:
int share_me = 0; // definition
C++ ignores the extern keyword if an initialization is present.