Föreläsningar

 

1 Kursens upplägg. Canvas. Git. Stacken, allokera dynamiskt minne (sid 458). Exempel på undefined behaviour delete/delete[] (sid 480) , returnera pekare till lokal variabel (sid 52). class vs struct (sid 268). semikolon efter class (sid 72)

 

2 Build C++, why headerfiles, header guard, #iostream, makefile, preprocessor, static/dynamic linking (sid 207), pointers, pointers to an array (sid 52).

pass by value vs pass by reference (sid 209)

use reference instead of pointers (sid 213)

reference (sid 51) binder en variabel och kan inte bindas om.

constructing object on the stack (sid 204 automatic objects)

namespace, using, scope-operator (sid 7, 794, 282), #include

method implementation syntax in cpp-file

 

3

const. why const. - readonly and compile-time. constexpr, extern const (sid 59-

pointers two kind of const, pointee and pointer (sid 62)

Construction of objects (sid 262)

inititializer list (kolon/init-lista), initializing reference member, order, delgating (sid 288-)

implicit vs explicit, consider explicit for all 1-argument constructors (sid 296)

Rule of three (or four or five in C++11) (sid 503) copy constructor, operator=, destructor, 

operators, operator+, operator+=, (sid 551)

array on the stack, 0-array on the heap

 

4

operator[], const och icke-const in matrix class. const print-method uses const-methods

private, protected, public.

Inheritance,  protected

array vs pointer int a[5] char* string

operator<< iostream and printf operators returning a reference vs returning a copy.

Virtual methods, virtual table, dynamic binding

5 namespace. using namespace std, using std::cout;

Introduction to templates. (s651 - 687)

Template parameters. Do not use T* in template <class T*> write template <class T> instead. Pointer as an iterator. 

Constructor inititializer list, intitializing a member refernce variable, 

6

Template specialization (s707)

template <int N> struct Factorial  { static constexpr int value = N * Factorial<N - 1>::value; };

template <> struct Factorial<0>  {static constexpr int value = 1;};

template specialization when optimizing example swap<Matris> 

std::move (s534 - 538) ges automatiskt om man det går och man inte definierat enbart copy-konstruktorn. =default försöker kompilatorn göra en move-konstruktor. Sätt värden på argumentet till default. 

Matris(Matris && m)

operator=(Matris && m)

Return value optimization (ej i boken, kompilatorteknik innan std::move)

static members, static methods, static in C.

 

7

lambdas, auto myfunction = [y eller = eller &] (int x) { return x + y; }  (s 388)

mutex, condition variable, notifyall (ej i boken)

function pointer std::function<int(int)> fpointer; 

functor --  operator()() as function pointer

pointers. unique_pointer, shared_pointers. unique_ptr<Foo> p1(new Foo) ;unique_ptr<Foo> p2(move(p1)) :p1 = move(p2) (s450)

Abstract class memberfoo=0()

skillnad interface java

diamantarv 

inline functions, mutable members, volatile variables,

 

 

 

 

7 How to remove a node in a binary search tree, pointer to reference. assert vs exception vs returning nullptrs. Why nullptr instead of NULL foo(int)/foo(char *) Implementeing a matrix with an array, erase_row/col nasty without nasty off_by_one error. Move constructor. is_move_constructible Links to an external site., std::move. Rule of three, How to write operator=, basic exception safety. explicit contructor considered. Template discussion continued, where to put template code. the auto keyword. vector<int>::iterator i = v.begin();

8 preparing for the exam, old exams

9  implementing iterators - return a pointer. Implementing an iterator over a vector, Iterating over a tree. Exception-safe programming. Chess pieces, representation. Slagschack.

overloading member function, operators, literals,