Ch 1: Review & Intro Flashcards

1
Q

what is ifstream & ofstream? (what do you use them for, how do you use them - functions)

A

ifstream & ofstream are file input streams that write to (ofstream) and get data from (ifstream) file inputs

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

what do you use ifstream & ofstream operators and how do you use them?

A
  • use insertion&raquo_space; and extraction &laquo_space;operators to get and write data
  • use similarly to cin: inFS», outFS«
  • # include
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a pointer and what does the data type of the pointer do?

A
  • pointer: holds a memory address
  • pointer data type determines what type of address the pointer will store (Ex. int* p points to address of an int variable)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is a reference(&), what are the dereference operators and what do they do?

A
  • reference(&): obtain a variable’s address
  • dereference operators: *, ->, []
  • dereference operators retrieve the data from the variable that the pointer points to (Ex. int a = *p, sets a to the data that pointer p points to)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the new operator?

A

new operator allocates memory into heap before calling constructor (ex. Point* point1 = new Point(___); )

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

what is the delete operator?

A

delete operator frees memory of variable in heap

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

how is an allocated array deleted?

A

delete[]

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

what is the advantage of linked lists over sequential storage approaches (arrays or vectors)?

A

items can be reordered, added and removed in linked lists without having to shift items

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

what is recursion?

A

calling the same algorithm(function) multiple times for smaller sets

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

what are the two functions for recursion?

A
  • outer: the function that is called from other parts of the program, calls the inner function
  • inner: called by the other function, does recursive action
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is an ADT, or abstract data type?

A

a data type whose creation and update are constrained to specific well-defined operations

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

do variables have to be declared before being used in class definition? how does this relate to inline member functions?

A

no, variables can be declared after its use in class definition. this relates to inline member functions because sometimes an inline member function calls on a variable that is defined afterwards, but the function definition is still valid

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

what is 100% code coverage?

A

every line of code is conducted

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

what are border cases?

A

unusual or extreme test case values

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

how does 100% code coverage relate to bugs in code?

A

100% code coverage does not ensure that there are no bugs in code

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

what is regression testing?

A

retesting an item like a class anytime the item is changed

17
Q

what is compile-time polymorphism?

A

when the compiler determines which function to call at compile-time

18
Q

what is runtime polymorphism?

A

when the compiler is unable to determine which function to call at compile-time so the determination is made while the program is running

19
Q

what is derived/base class pointer conversion? give an example

A
a pointer to a derived class is converted to a pointer to the base class without explicit casting- will call the function related to the vector list type instead of the item type
ex. buisnessList.push_back(restaurantPtr); -> restaurant pointer is converted to business pointer
20
Q

what does “override” do?

A

indicates that a virtual function in base class is overridden in derived class

21
Q

how is runtime polymorphism used without virtual and override?

A

runtime polymorphism wrks by using reference
ex. PrintDescription(restaurant); -> restaurant is passed by reference so functions called in PrintDescription will be from restaurant class, not business class (if there’s a printName function called in print description then it will call restauran’ts printName not business’s printName)

22
Q

what is an abstract class?

A
  • a class that guides the design of a subclass but cannot itself be instantiated as an object
  • has at least 1 pure virtual function
  • concrete class is the opposite of abstract
23
Q

what is a pure virtual function

A
  • a virtual function that is not implemented in the base class
  • virtual funcName () = 0;
  • in base class
24
Q

what is “this”?

A

used to get an object’s data member, points to the current object

25
Q

what is “Big Oh”?

A
  • formalized way to describe complexity
  • figures out how much a program function is going to “cost”
  • gives upper bound b/c we don’t care about constants, an overestimation