Ch_7_Classes_And_Objects Flashcards
::
Scope Resolution operator. It is needed to indicate class member functions and to inform the compiler which class it belongs to.
Member Function (Methods)
- A function that belongs to a class.
- The procedures that an object performs.
Class
- A programmer-defined data type used to define objects.
- The primary construct used to create objects.
Types of Member Functions (Methods)
- Acessor, get, getter function
-Mutator, set,setter function
Access Specifier
- Public or Private
- Specify which member variables and member function are accessible from inside and outside the class.
Data Hiding
- Refers to an object’s ability to hide its data from code outside the object.
- Only the object’s member functions can directly access and make changes to its data.
- An object typically hides its data, but allows outside code to access it through some of its member functions.
Encapsulation
Data and method together
Abstract Data Type
Any data type whose implementation details are kept separate from the logical properties needed to use it.
A data type that specifies the values the data type can hold and the operations that can be done on them without the details of how the data type is implemented.
Abstraction
A general model of something.
A definition that includes only the general characteristics of an object without the details that characterize specific instances of the object.
Data Abstraction
Separation of a data type’s logical properties from its implementation details.
Procedural Programming
A method of writing software centered on the procedures, or functions, that carry out the actions of the program.
Object Oriented Programming
A method of writing software that is centered on objects.
Objects
- A software entity that combines both data and the procedures that work with it in a single unit.
- Instances of a class.
Attributes
An objects data items. Stored in member variables.
Encapsulation
The bundling of an object’s data and procedures.
Instantiation
Defining a class.
Accessor (Get Functions; Getter)
A member function that USES the value of a class variable, but does not change it.
Mutator (Set Functions; Setter)
A member function which stores a value in a member variable, or changes its value.
Inline Function
Member functions that are defined within the class definition.
Function Implementation
A member function definition that is placed outside of the class declaration. A member function prototype will be placed in the class declaration.
Stale Data
Member data that has an external dependency and wasn’t changed when the dependency was changed.
Stack
Section of memory that holds the following when a regular function is called.
- Return address for when the function finishes executing.
- Values of the function arguments.
Constructor
A special PUBLIC member function that is automatically called when a class object is created.
Default Constructor
A constructor which has no parameters.
Member Initialization List
A list of member variable names with their initial values that appears after the constructor heading and before the opening brace of the body.
In-place initialization
Beginning with C++11 you can initialize member variables when they are defined inside the class declaration.
Constructor Delegation
In C++ 11, it is possible for one constructor to call another constructor in the same class.
Destructor
- A member function that is automatically called when an object is destroyed.
- Public member functions with the same name as the class, preceded by a tilde character (~).
- Have no return type, similar to constructors.
- Cannot accept arguments, so they never have a parameter list.
- There can only be one destructor.
Most useful when working with objects that are dynamically allocated.
Private Member Functions
- Member functions that may only be called from a function that is a member of the same class.
Constant Reference
To protect an object when it is passed as an argument, without having to make a copy, it can be passed a a constant reference.
This means that a reference to the original object is passed to the function, but it cannot call any mutator functions or change any of the object’s member data.
It can only call accessor functions that have themselves been designated as constant functions.
Object Composition
When one class is nested inside another.
Class Specification File
A header file that contains a class declaration.
Class Implementation File
A separate .cpp file that includes the member function definitions.
Structure
A programmer-defined data type that can hold many different data values.
Object Oriented Analysis Process
- Identity the classes and objects to be used in the program.
- Define the attributes for each class.
- Define the behaviors for each class.
- Define the relationships between classes.
Class Attributes
The data elements used to describe an object instantiated from the class.
Relationships Between Classes
- Access
- Ownership (Composition)
- Inheritance