lecture two: abstract data types Flashcards

(41 cards)

1
Q

how many “things” does an ADT have?

A

three

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are the three things an ADT has?

A

data
operations on the data
rules of usage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is an ADT?

A

an abstract data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what does ++i do?

A

increments then returns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what does i++ do?

A

returns then increments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you pass a parameter to a function when you don’t want the function to modify the parameter?

A

pass by value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how do you pass a parameter to a function when you want the function to modify the parameter?

A

pass by reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

if we abide by the rules of the ADT, what do we get?

A

an “insurance policy”, or a guarantee that the ADT will work and not break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the data of an ADT?

A

some amount of memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the operations of the data of an ADT?

A

a set of methods/functions that work on the data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the rules of usage of an ADT?

A

a set of rules that must be obeyed in order for the ADT to work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

when do we use ADTs?

A

all the time! bools and ints are a few examples of ADTs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are the three “things” for a bool ADT?

A

data: 1 bit, true or false
operations: and, or, not, xor, assignment
rules: boolean arithmetic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what are the three “things” for an int ADT?

A

data: 64 bits, 63 for value and 1 for sign
operations: +, -, *, /, assignment, «,&raquo_space;, etc.
rules: integer arithmetic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is class and what does it allow us to do?

A

Class is a construct that allows the language to be extended with addition of new types (ADTs)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what do we want ADTs to look like?

A

part of the programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what does encapsulation do?

A

binds data and operations in one place

18
Q

how does a class use information hiding?

A

it has public and private components, so the programmer can choose what is shared and what is not

19
Q

what does a class declare?

20
Q

what is an object?

A

an instance of a class

21
Q

what is a c++ idiom (standard practice) regarding .hpp and .cpp files?

A

.hpp files and .cpp files should be used to separate declaration from implementation files

22
Q

what is a .hpp file used for?

A

declare the class and associated functions and variables

23
Q

what is a .cpp file used for?

A

implementing the code

24
Q

what is the tool that is used to compile everything?

A

the make build tool

25
how does using .hpp and .cpp protect the intellectual property of the code?
you can ship just the .hpp file and the code will still work properly, but the people you shipped the .hpp file to will not be able to access the .cpp file with the implementation of the code
26
what is golden rule #1 of c++?
always have include guards for EVERY .hpp/.h file
27
what happens if you include a file twice in a program?
you will get an error because it tries to create variables and classes twice
28
what is the # for c and c++?
it is a preprocessor
29
is the # part of the c/c++ programming language?
NO, it is part of the c preprocessor language
30
what is an example of #include ?
#include because it includes a list of files from the c++ iostream
31
what is an example of #include "current folder" ?
#include "point.hpp" because it only includes this one file
32
what does #ifndef SYMBOL do?
if the symbol is not defined, then include the lines to the #endif. If the symbol is defined, then skip the code
33
what does #define SYMBOL do?
defines a symbol and a possible value
34
what does #include do?
includes the file or list of files you put after the include
35
what do you have to have after an #endif statement?
a blank line (no code on that line)
36
when you define a symbol, what should you never do?
use a leading underscore
37
what can the output stream (ostream) be passed as?
it can ONLY be passed as a reference
38
what is :: and what does it do?
:: is the scope resolution operator and it tells the compiler which class to implement code to & gives access to private variables of the class
39
what is a method?
a function that is bound to a class
40
what is a free function (or just a function)?
a function that is not bound to a class
41
what do we never use in programs in this class?
using std