OOP1 Classes Flashcards
Data representation
The concrete existing data types used to create an abstract data type
Abstract data type
A user defined data type that has a properties of domain (data), and operations, also known as a class, which is independent of any particular implementation
Constructor
An operation/method that instantiates a new variable/object of the class type
Destructor
A method that destroys and deallocates the memory for an class instance variable
Transformer/mutator
A method/operarion that changes the value of an instance of a class , or an object
The state
The current state of an object / class instance
Observer / accessor
A method/operation for accessing and observing the state or part of the state of a class instance/object
Iterator method
A method that successively returns each item in a specific list of a class instance
What does the specification of an ADT describe?
It specifies the data values and operations in an abstract way that can be given as documentation to both user and programmer
What are the two things a programmer must do to implement an ADT?
- Choose a concrete data representation using existing data types
- Implement each of the allowable operations in terms of program instructions
Class
A data type that is used to represent an abstract data type
Why are classes useful?
An entity’s data and operations may not well be split apart, sometimes they act better as a single cohesive unit
How are classes defined?
class keyword, {} definition block, containing declaration of data members and operations, with access modifiers, terminated by ;
What is an access modifier?
A keyword used when declaring data types and methods for a class that specifies how they might be externally accessed
What does private access modifier do?
Prevents implementations external to the class from accessing it
When are constructors invoked?
They are invoked at instantiation
What is a default constructor?
A parameterless constructor that is invoked implicitly as a default unless otherwise specified
What is a class client?
Any implementation that creates and manipulates instances of a class