Programming in C++

Programování v C++

NPRG041

2023/2024

David Bednárek

Katedra softwarového inženýrství

C++ je v nějakých ohledech tak bizarní jazyk, že si říkám, že musí být mimozemského původu. [anketa 2021/22]

Warning (particularly to Erasmus students) - before you enroll to this course

This course assumes that all participants already acquired some experience in programming, understanding of object-oriented programming, and basic knowledge of C (or C++) and C# or Java. If you are a beginner in programming, you shall not enroll. If your experience covers only python, PHP, JavaScript, Pascal, FORTRAN, or similar languages, you may expect problems understanding some parts of the lecture.

For regular students of Computer Science, this assumption is covered by the prerequisities of the subject.

Varování

Předmět předpokládá u všech účastníků zkušenosti s programováním, porozumění objektově-orientovanému programování a základní znalost jazyka C (nebo C++) a C# nebo Java. Pokud jste v programování začátečník, nezapisujte se. Pokud máte zkušenosti pouze s jazyky jako python, PHP, JavaScript, Pascal nebo FORTRAN, budete mít problém s porozuměním některým částem přednášky.

Pro pravidelné studenty programu Informatika jsou tyto předpoklady zajištěny prerekvizitami předmětu.

Communication

For communication on all aspects of this course, please use Mattermost. (Your emails are often classified as junk.)

For the first logging-in, you will need an invite-link, placed in the Notice-board module in the SIS. (This invite link is valid for several courses that share the same Mattermost team 2324ZS for this semester.)

The channel nprg041-english is dedicated for the English=speaking students. The channel is intended for communication between teachers and students, as well as related discussions between students. In addition, you may use direct messages for non-public communication.

Komunikace

Pro komunikaci s vyučujícími používejte přednostně Mattermost. (Vaše emaily bývají často považovány za spam.)

Pro první přihlášení budete potřebovat invite-link, který najdete na Nástěnce předmětu v SISu. (Tato pozvánka platí pro team 2324ZS pokrývající několik předmětů vyučovaných v ZS 2023/24.)

Tohoto předmětu se týkají kanály nprg041-cpp-[cvicici] pro cvičení daného vyučujícího a nprg041-cpp-repetenti pro repetenty. Všechny tyto kanály slouží pro komunikaci mezi vyučujícími a studenty i k diskusím mezi studenty týkajícím se předmětu. Pro neveřejnou komunikaci použijte direct messages.

Tutorials and credits

Mon 15:40 SW2

The exact conditions for receiving course credit are set by the teacher of the tutorials. The main parts of course credit are

  • Credit test - see below, required for admission to exam
  • Programming project - topics and deadlines individually arranged with the teacher, final version typically delivered during the summer semester

Cvičení

Skupiny a pravidla pro cvičení a zápočty

Pravidla pro repetenty a studenty s rozloženým ročníkem

Přesné podmínky pro získání zápočtu stanoví příslučný cvičící. Hlavními podmínkami udělení zápočtu jsou

  • Zápočtový test - viz níže, nutný pro připuštění ke zkoušce
  • Zápočtový program - témata a termíny individuálně dohodnuty s cvičícím, finální verze typicky odevzdána během letního semestru

Credit tests and exams

The credit tests and exams take place in a computer lab (S[UW][12]). To ensure equal environment, students must use only the computers of the lab, either in Windows or in Linux mode. The use of notebooks (or other computing devices not installed in the lab) is not allowed during the exam. Students shall not use any resource other than the compiler, debugger, editor and/or IDE installed at the lab and the language reference manuals at cppreference.com or cplusplus.com. Before attempting an exam, make sure that you are familiar with the development environment at the lab computers.

Each student must work independently.

Credit test

Each group will have a final homework assignment during the semester. The credit test assignments of students in this group will be based on an extended or modified version of this final homework; students will be allowed to download and edit their final homework solution from the recodex during the credit test.

The credit test will last 90 minutes, including the presentation of the assignment and the necessary handling of the recodex, so probably no more than 60 minutes will be left for solving the task itself. It would be extremely difficult to create the entire solution to this task during the credit test. It is therefore in the interest of every student, before the credit test, to create (and insert into the recodex) such a solution to the final homework, which does not obstruct further modifications and extensions.

The decision on successful completion of the credit test will be based not only on the result of the automated tests in the recodex, but also on the assessment of the source codes by the teacher.

Each student has two attempts to pass the credit test.

The standard credit test will be held at the last session of the given group, i.e. in the last week of classes.

The second date of the credit test will take place in the first half of the exam period. Although the date will be shared among multiple groups, each student will be assigned a task related to their group's final homework. (However, it will be a different version than at the standard term.)

Although there may be more than one secondary credit test date (depending on the total number of students who failed the basic dates), only one of these terms will be available for a given group.

Exam

The successful completion of the credit test is required for admission to the exam. Students who pass the credit test only at the second date will thus be deprived of the opportunity to take the exam in the first weeks of the exam period.

The content of the exam is the programming of an assigned task within a time limit of 3.5 hours, including submission to the recodex system. All students solve the same task in a given term.

The evaluation of the exam will be based not only on the result of the automated tests in recodex, but also on the assessment of the source codes.

In accordance with the study regulations, the exam can be taken three times, the last result counts.

All the exam dates published in SIS are mixed Czech/English. Exams will be supervised by various teachers, the examiner name mentioned in SIS is just a placeholder.

Zápočtový test a zkouška

Zápočtové testy i zkoušky se konají v počítačové laboratoři (S[UW][12]). V zájmu zajištění stejných podmínek musejí studenti používat pouze počítače instalované v laboratořích, v režimu Windows nebo Linux. Použití notebooků (nebo jiných výpočetních prostředků, které nejsou součástí laboratoře) během zkoušky není povoleno. Studenti nesmějí používat jiné zdroje než překladače, debuggery, editory a IDE instalované v laboratoři a referenční manuály k jazyku na stránkách cppreference.com nebo cplusplus.com. Před zápočtovým testem se ujistěte, že umíte pracovat s vývojovým prostředím instalovaným na počítačích v laboratořích.

Každý student musí pracovat samostatně.

Zápočtový test

V každé skupině bude během semestru zadán finální domácí úkol. Zápočtové testy studentů této skupiny budou založeny na rozšířené nebo upravené verzi tohoto finálního domácího úkolu, přičemž studentům bude při zápočtovém testu umožněno stáhnout si své řešení finálního domácího úkolu z recodexu a upravovat jej.

Zápočtový test bude trvat 90 minut včetně prezentace zadání a manipulace s recodexem, na samotné řešení úlohy tedy pravděpodobně nezbude více než 60 minut. Vypracovat celé řešení tohoto úkolu během zápočtového testu by bylo extrémně obtížné. Je tedy v zájmu každého studenta, aby před zápočtovým testem vytvořil (a vložil do recodexu) takové řešení finálního domácí úkolu, které svým provedením nezkomplikuje další úpravy a rozšíření funkčnosti.

Rozhodnutí o úspěšném splnění zápočtového testu bude založeno nejen na výsledku automatizovaných testů v recodexu, ale rovněž na posouzení zdrojových kódů příslušným cvičícím.

Na absolvování zápočtového testu má každý student dva pokusy.

Základní termín zápočtového testu se bude konat na posledním cvičení dané skupiny, tj. v posledním týdnu výuky.

Opravný termín zápočtového testu proběhne v první polovině zkouškového období. Opravný termín bude společný pro více skupin, každý student však dostane úlohu založenou na finálním domácím úkolu jeho skupiny. (Bude to však jiná verze než při základním termínu.)

Celkový počet vypsaných opravných termínů bude stanoven podle celkového počtu studentů neúspěšných při základních termínech. Pro danou skupinu však bude určen pouze jeden z těchto termínů.

Zkouška

Podmínkou připuštění ke zkoušce je úspěšné splnění zápočtového testu. Studenti, kteří splní zápočtový test až při opravném termínu, tak budou ochuzeni o možnost konání zkoušky v prvních týdnech zkouškového období.

Obsahem zkoušky je naprogramování zadané úlohy v časovém limitu 3,5 hodiny včetně odevzdání do systému recodex. Všichni studenti v daném termínu řeší tutéž úlohu.

Hodnocení zkoušky bude založeno nejen na výsledku automatizovaných testů v recodexu, ale rovněž na posouzení zdrojových kódů.

Zkoušku lze v souladu se studijními předpisy konat třikrát, počítá se poslední výsledek.

Všechny termíny zkoušek v SISu jsou smíšené česko-anglické. Zkoušky budou dozorovány různými vyučujícími, jméno zkoušejícího v SISu není relevantní.

Timetable

Warning: The videos from previous years do not necessarily cover all the currently required topics.

Date Slides Topics Video
2020/21
Video
2021/22
2023/10/2 1..17 Pros and cons of C++. Compilation and header files.
2023/10/9 18..26
1..8 Hello, world. Modules, declarations and definitions, references.
2023/10/16 9..14
1..12 Values, pointers, references.
10-21
2023/10/23 1..18 Passing arguments and returning by value and by reference, copy/move semantics, copy/move elision.
11-04
2023/10/30 19..28 11-11
1..6 Copy/move semantics, the Rule of Five. Pointers, smart pointers, observers.
2023/11/06 7..13 11-18
2023/11/13 14..17
1..8 References vs. pointers, conventions. Containers, iterators. 11-25
2023/11/20 9..21 12-02
12-09
2023/11/27 1..18 Algorithms, functors, lambda. 12-16
2023/12/04 1..17 Templates, forwarding references. Variadic templates.
2023/12/11 18
1..14 Traits, policy classes, functors, tags.
1..6 Classes, inheritance, virtual methods. Conversions. 01-06
2023/12/18 7..22
2024/01/08 23..28
1..23 Introduction to exceptions.
Additional slides not covered by lectures
1..16 Visitor pattern, std::variant.

Průběh přednášky

Varování: Videa z předešlých let nemusejí pokrývat všechna aktuálně požadovaná témata.

Datum Slajdy Témata Video
2020/21
Video
2021/22
5.10.2023 1..17 Výhody a nevýhody C/C++. Kompilace, hlavičkové soubory, dělení do modulů. 09-29
12.10.2023 18..26
1..14 Hello, world. Předávání hodnotou a odkazem. 10-06
10-19
19.10.2023 1..12 Hodnoty, ukazatele, reference. 10-13
10-26
1..3 L-value a R-value reference. Copy/move. Předávání parametrů a vracení hodnotou a odkazem, fyzická a logická konstantnost. 10-20
26.10.2023 4..11 11-02
9.11.2023 11..20
10-27 11-09
1..8 Copy/move-elision, lvalue/rvalue, copy/move metody. Rule-of-Five.
16.11.2023 9..18 11-16
1..10 Dynamic allocation, smart pointers, observers. Konvence používání ukazatelů a referencí. Arrays vs. vectors, smart pointers vs. containers. 11-03
23.11.2023 11..15 11-23
1..9 Kontejnery, iterátory, range-for-loop. Algoritmy. 11-10
30.11.2023 10..18
1.. Funktory, lambda, std::function. 11-24
12-14
7.12.2023 1..13 Šablony, forwarding references, variadické šablony. 12-01
14.12.2023 14..18
1..14 Traits, policy classes, functors, tags.
21.12.2023 1.. Class vs. namespace. Dědičnost. 12-15
4.1.2024 ..31
1.. Výjimky.
11.1.2024 ..26
Doplňkové slajdy nepokryté přednáškami
1..4 std::variant. 12-08 12-21
1..12 Visitor. 12-22