Ch 1: Review & Intro Flashcards
what is ifstream & ofstream? (what do you use them for, how do you use them - functions)
ifstream & ofstream are file input streams that write to (ofstream) and get data from (ifstream) file inputs
what do you use ifstream & ofstream operators and how do you use them?
- use insertion»_space; and extraction «_space;operators to get and write data
- use similarly to cin: inFS», outFS«
- # include
what is a pointer and what does the data type of the pointer do?
- 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)
what is a reference(&), what are the dereference operators and what do they do?
- 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)
what is the new operator?
new operator allocates memory into heap before calling constructor (ex. Point* point1 = new Point(___); )
what is the delete operator?
delete operator frees memory of variable in heap
how is an allocated array deleted?
delete[]
what is the advantage of linked lists over sequential storage approaches (arrays or vectors)?
items can be reordered, added and removed in linked lists without having to shift items
what is recursion?
calling the same algorithm(function) multiple times for smaller sets
what are the two functions for recursion?
- 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
what is an ADT, or abstract data type?
a data type whose creation and update are constrained to specific well-defined operations
do variables have to be declared before being used in class definition? how does this relate to inline member functions?
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
what is 100% code coverage?
every line of code is conducted
what are border cases?
unusual or extreme test case values
how does 100% code coverage relate to bugs in code?
100% code coverage does not ensure that there are no bugs in code
what is regression testing?
retesting an item like a class anytime the item is changed
what is compile-time polymorphism?
when the compiler determines which function to call at compile-time
what is runtime polymorphism?
when the compiler is unable to determine which function to call at compile-time so the determination is made while the program is running
what is derived/base class pointer conversion? give an example
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
what does “override” do?
indicates that a virtual function in base class is overridden in derived class
how is runtime polymorphism used without virtual and override?
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)
what is an abstract class?
- 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
what is a pure virtual function
- a virtual function that is not implemented in the base class
- virtual funcName () = 0;
- in base class
what is “this”?
used to get an object’s data member, points to the current object
what is “Big Oh”?
- 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