Hide menu

TDDD38 Advanced Programming in C++


Seminar 1 is given as a quick introduction to basic C++, actually prerequisites. If already familiar with C++11, you may consider to skip seminar 1, but have a look at the material.

All the old lecture slides are available as pdfs for each seminar. There is also a rendering in HTML available with links to the topics covered here

Full size seminar slides are linked from each topic heading. [2x2] shows miniatures, 4 slides per page. Also the two larger, complete code examples used for seminar 4—5 (String) and seminar 6—7 (P-E-M-C) are linked below.

Extra material will be added here during the course and on the course GitLab group.

Seminar plan for study period Vt1, week 3—10

Intro lecture 
Jan 18  

Introduction and overview [Language overview2x2]
Introduction to the course. Overview C++.

Seminar 1 
Jan  27 / 28  

Basic C++ (1)  [2x2]
Overview of types (fundamental, compound, aggregates), type conversion, declarations, expression, operators, statements, characters, strings, streams, string streams, file handling, functions, parameter passing, dynamic memory handling, list initialization.

Example code

Excercises: Aggregates and List initialization

[an error occurred while processing this directive]

seminar 2 
Feb 3 / 4  

Classes  [2x2]  [Code example String]
Definition, declaration; members, data members, member functions, nested types, enumerators, static members, const member functions, mutable, inline; this (expression which gives the address for the object the member function has been called for); access specification (public, protected, private), friend; implicitly defined operations on class types (member access, scope operator); special member functions (default constructor, copy constructor, copy assignment operator, destructor), compiler generated versions of the special member functions; initializers, type converting constructors, explicit, type converting operator functions; recommendations for single class design.

Excercises: Aggregates and List initialization

Operator overloading  [2x2]
Rules and restrictions; member or non-member?; friend or not? Overloading, optimized versions. Guidelines and recommendations for definition and overloading of operators.

Example on copy elision

Excercises: Aggregates and List initialization  |  Smart pointer

[an error occurred while processing this directive]

seminar 3 
Feb 17 / 18  

Derived classes, polymorphism, RTTI   [2x2]  [Code example P-E-M-C]
Derivation/inheritance; base class/subclass; singe, multiple and repeated inheritance; public, protected and private inheritance; virtuellt inheritance (virtual); protected member access; virtual function, pure virtual function, pure specifier (=0); polymorf class, abstract class; static type, dynamic type; dynamic type control, dynamic type conversion, RTTI, dynamic_cast, typeid, type_info-objects; up-cast, down-cast, cross-cast;

Exception handling  [2x2]
Try-block, function-try-block, throw-expression, catch-handler; exception specification (for function), exception declaration (in handler); "catch-all" handler; bad_exception; terminate(), unexpected(), uncaught_exception(), abort(); standard exceptions (exception and subclasses); user defined exceptions; recommendations for using exceptions.

An example on RAII and exceptions: Neitwork mock library

Excercises: Geometric objects

[an error occurred while processing this directive]

seminar 4 
Mar 2 / 3  

Links to ask and vote for questions: Mar 2 | Mar 3 Templates  [2x2] Templates
Function templates, class templates; declaration, definition; template parameters, template arguments, default template parameter arguments; template instantiation, implicit instantiation, explicit instantiation; template specialization, implicit specialization, partial specialization, full specialization; function templates and overload resolution; variadic templates, parameter pack, pack expansion; type equivalence for template classes; member templates; friend and template; alias templates; dependent name; SFINAE; The name rule, reference collapsing rules, move semantics, perfect forwarding; template meta programming, type traits; compilation models for template code.

Namespaces  [2x2] (if time allows)
Namespace, namespace members, anonymous namespaces, namespace alias, using declaration, using directive (using namespace).

Preprocessor  [2x2] (if time allows)
Source code inclusion, simple macros, function macros, conditional compilation.

Excercises: Policy Design for Smart Pointers  |  The Curiosly Recurring Template Pattern (CRTP)  |  Character Traits

[an error occurred while processing this directive]

seminar plan for study period Vt2, week 14—21 (dates will be given at a later occasion)

seminar 5-?  

C++ standard library (1)
Main emphasis on containers, iterators, algorithms, function objects, and related library support.

Introduction, overview  [2x2] Introduction, overview  
General overview. Containers, iterators, algorithms, function objects, utilities.

Standard containers  [2x2] Standard containers  
Sequential containers, sequential container adaptors, ordered associative containers.

Iterators  [2x2] Iterators  
Container iterators, inserters, stream iterators.

Standard algorithms  [2x2] Standard algorithms  
Algorithms (function) for operating on, e.g., containers, streams, etc.

Function objects, lambda expression  [2x2] Function objects, lambda expression  
Objects that can be used as functions. Important for effective use of containers and algorithms. Lambda exepressions is a way to create simple function objects. Binders, negators, function call adaptors, and standard function objects corresponding to the arithmetic, comparison, and logical operator in C++.

Excercises: Container Design  |  Fixed Size Container  |  Indexable Set  |  Ordered List Iterators  |  Standard Library

A collection of short segments.
The <chrono> header
The <random> header
The <ratio> header
Regular expressions
Smart pointers

CppCon 2015: Michael VanLoon "STL Algorithms in Action" [1h]
Why should you use them? Basic layout / structure and lots of good examples.
CppCon 2015: Sean Parent "Better Code: Data Structures" [1h 4min]
Stephan T. Lavavej's (likes to go by STL) Channel 9 lectures on the STL (part 1 here)
There are 16 separate videos. All were released pre-C++11 but he's head of the VC implementation of the STL so he regulary shows their pre-release version implementation (which is of course a bit more refined by now)

Extra material
A collection of material that didn't really fit into a specific topic.
The range based for loop and the auto keyword
User-defined literals

[an error occurred while processing this directive]

Page responsible: Eric Elfving
Last updated: 2016-04-08