SE 2040
Topics for Spring, 2019
Note 2
: Basic Ruby
Note 3
: [2..Ruby]
Procedural, OO programming in Ruby, including attributes and class variables
Ruby functions
Range, Array, Hash types
Ruby type system, open classes
map, each operations with blocks
Standard input; standard output; redirection with <, >, |
Exercise: count number of negative values in a list read from a file that is given as standard input
Note 5
: C++ 101
Why C++/similarities and differences from Java
Why no static void main?
Basic data types of C++, differences from Java
Declaring variables using type
auto
Operations, including sizeof
Number of bits in a byte, number of bytes in a character
sizeof
relationships for built-in types
Scope and lifetime
Memory maps
Declare identifier before can use it
const
Arrays in C++ vs. Java, allocating array on stack vs. heap
Declaring, dereferencing pointers
Given
char *p
, knowing the difference between
p
,
*p
, and
&p
Count number of negative values in an array of doubles without using
[]
nullptr
Initial value of
int xs[100];
(depending on where declared)
Floating-point constants: 6.022e23
Note 6
: C++ classes
How would you define
std::string
? (naive implementation with
.size
,
.length
,
.empty
,
.clear
,
+=
,
==
,
[]
)
private vs protected vs public
Exercise: implement a simply linked list in C++
Note 7
: Modularity in C++
#include
, separate compilation
declaration vs. definition
define a function
negatives
that takes an array of doubles and returns a count of those less than 0
declaration before use rule
separating method definitions from class definitions - what does this mean?
standards for .h (header) files
explaining the steps of compilation, why it matters whether an error is a compiler error vs. a linker error
namespace
Note 8
: C++ with class
inheritance, abstract types,
=delete
why have inheritance
Given class A and B derived from A, knowing if an
A*
variable can point to a
B*
value
virtual vs. non-virtual methods, vtable
l-value vs. r-value
pass-by-reference vs. pass-by-value
return by reference
pure virtual methods
Note 9
: C++ Templates
writing a template function, class
example: template function to compute average of an array of numbers - what would be the header, body?
template class to store 3 items with .one, .two, and .three
duck typing with templates
Note 10
: Overloading/copy/move, STL, strings
Rule of 5: what are the items, why they are needed
recognize move constructor, explain what it does
write copy constructor
explain elements of assignment operator
given
std::string x;
, risk of storing
x.c_str()
in a variable/object
Note 11
: Streams, formatting
passing
istream
,
ostream
by reference
eof-controlled-loop pattern; why
while ( !
eof
) {
read; process
}
is a bad idea
purpose of
stringstream
: convert other data types into strings or from strings
using
ifstream
to read files,
ofstream
to write
Note 12
: Containers, algorithms
list<T>::iterator
,
list<T>::const_iterator
,
vector<T>::iterator
,
vector<T>::const_iterator
begin
: first element
end
: just
after
last element
Example: if
std::vector<double> nums(100);
gives an array of 100 items,
begin()
returns
&nums[0]
and
end()
returns
&nums[100]
roll of
#include <algorithm>
; esp
sort
,
reverse
,
fill
arguments to
sort
,
reverse
: iterators
Note 13
: C
goals
differences, similarities to C++
compilation units, linker,
static
,
extern
In particular, being able to explain what job linking accomplishes.
Makefiles; capturing dependencies and actions,
make
command
printf/scanf to print/read an integer, string, character
arrays vs. pointers, computing addresses
two-dimensional arrays, computing addresses with 2-d arrays
#define
, dangers of using
#define
instead of templates
#if
...
#else
...
#endif
Note 14
: Structs, unions, strings
typedef struct { ... } name;
passing structs as parameters
what
union
means
C-style strings, strlen, strcpy, strcat, strcmp
Note 15
: memory in C (& C++), stacks
be able to explain how stack is managed: what is FP, why FP-1 might be first local variable, given a layout how is data stored in that layout (including with pointers)
memory layout: text, rodata, data, bss, heap, stack
using
malloc
and
free
Note 16
: Types
three definitions of a type
advantages, disadvantages of
int8_t
,
int16_t
, etc.
what
void*
means, how used in C
differences between C and C++ type systems
casting using (type)
Ada and type equivalence rule based on names
Dangers of Ada's name equivalence type system
strongly typed
: same results on all machines independent of representations
what it means to create a function pointer, how it is useful in C
Note 17
: Ruby Blocks (if covered)
what is a lazy list?
how to use a lazy list
what
Prime.lazy.drop(5).first(3)
would return
what "execute around" means; be able to read code using it