lecture two: abstract data types Flashcards
(41 cards)
how many “things” does an ADT have?
three
what are the three things an ADT has?
data
operations on the data
rules of usage
what is an ADT?
an abstract data type
what does ++i do?
increments then returns
what does i++ do?
returns then increments
how do you pass a parameter to a function when you don’t want the function to modify the parameter?
pass by value
how do you pass a parameter to a function when you want the function to modify the parameter?
pass by reference
if we abide by the rules of the ADT, what do we get?
an “insurance policy”, or a guarantee that the ADT will work and not break
what is the data of an ADT?
some amount of memory
what is the operations of the data of an ADT?
a set of methods/functions that work on the data
what is the rules of usage of an ADT?
a set of rules that must be obeyed in order for the ADT to work
when do we use ADTs?
all the time! bools and ints are a few examples of ADTs
what are the three “things” for a bool ADT?
data: 1 bit, true or false
operations: and, or, not, xor, assignment
rules: boolean arithmetic
what are the three “things” for an int ADT?
data: 64 bits, 63 for value and 1 for sign
operations: +, -, *, /, assignment, «,»_space;, etc.
rules: integer arithmetic
what is class and what does it allow us to do?
Class is a construct that allows the language to be extended with addition of new types (ADTs)
what do we want ADTs to look like?
part of the programming language
what does encapsulation do?
binds data and operations in one place
how does a class use information hiding?
it has public and private components, so the programmer can choose what is shared and what is not
what does a class declare?
a data type
what is an object?
an instance of a class
what is a c++ idiom (standard practice) regarding .hpp and .cpp files?
.hpp files and .cpp files should be used to separate declaration from implementation files
what is a .hpp file used for?
declare the class and associated functions and variables
what is a .cpp file used for?
implementing the code
what is the tool that is used to compile everything?
the make build tool
- ?