Things You Need To Know for the CS 120 Final

Bits, Bools, Bytes, Chars, Ints, Floats

Concept of "Data Type"

	int, double, string, char, void, boolean, float
	cast is an explicit type conversion
		double d = 3.1415;
		int i = int(d);
	type promotion or demotion
		double d = 3.1415;
		int i = d;
conditionals!
	if
	if-else
	switch

loops!
	while
	do-while
	for


variables!
	a name for a chunk of memory! holds a value of some type
	must be initialized or you get junk
	global (visible everywhere) or local (visible in one scope)
	name rules: must begin w/ a letter or underscore

case sensitivity -- lexical rules of C++

operators and order of operations (precedence and associativity)
	+-*/% >,<,==,<=,>=,!=  &&,||,!
	= ++ -- &

int x;

string class: initialization from " ",
	+
	.c_str()
	.size()

double f(double x, double y)
{
    return x + y;
}

int main()
{
double x;
cin >> x;
cout << f(x, 1.2) << endl;
}


classes
	private (accessible only from member functions) and public
	members: variables and function
	declaring the class (class foo {...}) vs. implementation
	foo::funcname() { }
	o.funcname();
	proper use of .h files: no code in there!
	constructor - initializes objects/instances of the class
		function by-product of creating an object

files and streams!
	ifstream, ofstream
	libraries and include files #include 
	open and close; by the way, open can fail!
	<< operator sends stuff to an output stream...
	>> operator inputs stuff from an input stream...
		cin.ignore() - skips over a newline

Functions

syntax, semantics
formal parameters
return types
output from a function when it finishes
declarations (prototype)
specify parameters and return types
actual parameters
information passed in to a function when it is called
reference parameters vs. regular parameters
write your own functions define (body) - declare+{ sequence of statements } call. supply arguments (actual parameter)

Arrays

syntax, semantics, as parameters, multi-dimensional
0-based indexing and its practical consequences
be able to declare a big array and initialize its elements
visitor pattern, searcher pattern, reducer pattern
debugging arrays

Structs and Classes

syntax, semantics, how to declare and use
what can and can't be a struct element
relationship between struct and class
write a class definition from a verbal description
what to make private
class member functions
Accessors vs. Mutators
constructor, (destructor)

Pointers

syntax, semantics, how to declare and use
pointer dereferencing, * and ->
array/pointer duality law
dynamic memory, new and delete (ch07, slides 128-156+)

Files

how to open, close
how to read values into an array

Base Conversion

convert numbers from base 2 to base 10 and back
convert base 10 to base 16 and back
find the 2's complement of a binary number
2's complement binary addition

Linked Lists

how to declare and use
how to insert at the front, in the middle, or at the end
how to delete at the front, in the middle, or at the end