Shared Flashcard Set

Details

CMSC 270 midterm 1
adsv
44
Computer Science
Undergraduate 2
04/26/2014

Additional Computer Science Flashcards

 


 

Cards

Term
header file
Definition
declare structure of class
Term
source file
Definition
method definitions, .cpp
Term
driver file
Definition
has main method
Term
main is a "free function" means
Definition
it exists without/outside of any class
Term
#include (system/user)
Definition
like the java import statement
system: <>
user: " "
Term
open file stream and use
Definition
ofstream out;
out.open("numbers.txt");
out << "Hello, world!" << endl;
out.close();
Term
class level (static) members
Definition
class variable: shared by all instances of class
class constant: (final) shared by all instances of class
class method: does not operate on specific object
Term
global variables
Definition
outside the scope of any function or class
Term
globals (memory storage)
Definition
global vars, static class member cars, static local vars
stored in GLOBALS AREA
Term
stack (memory storage)
Definition
parameters, non-static (normal) local variables
stored in CALL STACK
Term
heap (memory storage)
Definition
dynamically allocated (with new)
stored on heap
Term
why using globals is shitty
Definition
who knows who/what is responsible for setting values
not self-contained
not easy to update program
Term
garbage collection
Definition
is necessary, unlike in java, so use delete to get rid of ur shit when you are about to orphan something
Term
memory leak
Definition
when u don't delete inaccessible objects off the heap
Term
static v. dynamic arrays
Definition
static: fixed in size, declare via int A[100]
dynamic: on heap, with new int*B = new int[100]
Term
pointer arithmetic
Definition
u can do it
Term
passing parameters: general rules
Definition
all individual values and objects are passed by value, only arrays are automatically passed by reference because they are really just pointers anywho
Term
const
Definition
makes it so can't modify that
Term
template class
Definition
just write template before class declaration, and then use T for things
to write it's member functions, have to put template before again
Term
overload operator
Definition
Time& Time::operator+=(const Time& other)
{ stuff }
binary ones (like +) should be written as free functions because more flexible
Term
operator signature
Definition
order of types of parameters, return type (need these to overload operators)
Term
friend
Definition
class A can be accessed by method B.m if A grants B "friend" status
Term
principle of data abstraction
Definition
a user's code should not access the implementation details of the class used
Term
iterator
Definition
object that enables a user to loop through a container without violating the principle of data abstraction
Term
public, private, protected, friend
Definition
public: can be accessed anywhere
private: can only be accessed within the class
protected: private but can be accessed in subclasses too
friend: all members of A can be accessed by B.m method if A grants B friend status
Term
template parameter
Definition
type that will be replaced by the template argument when the container object is defined
Term
how to overload post increment
Definition
pass in dummy parameter

Iterator itr(nodePtr); nodePtr = nodePtr -> next; return itr;
Term
destructor
Definition
method that deallocates the space occupied by an object
~Linked();
Term
template functions aka
Definition
generic algorithms
Term
generic algorithms operate on containers through iterators
Definition
idk just remember that
Term
sequential container classes
Definition
items are stored in succession, from first to last
Term
vector
Definition
finite sequence of items such that
1. item at index can be accessed/modified in constant time
2. insert/delete at back takes constant time on avg
Term
unsigned
Definition
idk check this
Term
amortized time
Definition
~cost, total number of statements executed in any sequence of n calls to the method, divided by n
Term
deque
Definition
finite sequence of items such that
1. item at index can be accessed/modified in constant time
2. insert/delete at front or back takes constant time on avg

very similar to vector
Term
list (linked list)
Definition
finite sequence of items such that
1. access/modify arbitrary item takes linear time
2. given iterator to position, insert/delete takes constant time
Term
why not use [ ] with list
Definition
it is deception
Term
choose vector/ deque or list
Definition
vector/deque: access/modify at different positions
list: insert/delete at iterated through positions
Term
constructor-initializer
Definition
in constructor make a field in it too
iterator(list_node* x): node(x) { }
initialize iterator's node field to x
Term
equality: reference, value, or user-specific semantics
Definition
reference: same address
value: different objects with identical contents
user-specific: based on certain field or whatever
Term
queue
Definition
container in which:
1. insert only at back
2. delete/modify only at front
FIFO
no iterator
deque is default, can also do lists
Term
container adaptor
Definition
calls methods from some other class to define its methods (ex: queue, stack)
Term
stack
Definition
container in which only item that can be removed/accessed/modified is at top (most recently inserted)
works with vector, deque, list, deque is default
Term
stack frame
Definition
info saved for calling function in case it goes back to it and needs to continue with something
Supporting users have an ad free experience!