Programming in C++
Labs, Wednesday 10:40–12:10, SW2, Malá Strana, 2026
Contact
-
Mattermost: ulita.ms.mff.cuni.cz/mattermost
- Channel:
2627/nprg041-cpp-faltin - DM:
@faltin.tomas
- Channel:
- Email: tomas.faltin@matfyz.cuni.cz
General Information
Useful Links
-
Gitlab
- Usage: Merge Requests
- Online compilers: Godbolt, Coliru
- Documentation: cppreference.com
- AI tools
- Package managers: vcpkg, Conan
Important Dates
Do not leave this until the last minute! Iteration takes time.
Individual Labs
| Lab | Date | Goals | Code | Homework |
|---|---|---|---|---|
| 01 | 30.09. | Organization | – | – |
| 02 | 07.10. | Hello World, compilation, IDEs, vector
|
– | Simple Calculator (deadline 23.10.) |
| 03 | 14.10. | classes, methods, const-correctness, argument passing - ref/val | – | Matrix (deadline 30.10.) |
| 04 | 21.10. | |||
| Holiday: Den vzniku samostatného československého státu | — | — | ||
| 05 | 04.11. | |||
| 06 | 11.11. | |||
| 07 | 18.11. | |||
| 08 | 25.11. | |||
| 09 | 02.12. | |||
| 10 | 09.12. | |||
| 11 | 16.12. | |||
| 12 | 06.01 |
Merge Requests in GitLab
Always submit your solution through a Merge Request (MR). This allows me to review your code and provide comments.
- Create a separate branch, e.g, hw1-solution for your homework:
git checkout -b hw1-solution - Add you solution and push your new branch to Gitlab
- Open a Merge Request
- Go to you Gitlab project in browser and click:
Merge Requests/Create merge request. - Select Source branch:
hw1-solution, Target Branch:master - Add a title, optional description, set
@faltintas Assignee, and click Create merge request
- Go to you Gitlab project in browser and click:
AI usage
-
e-infra
- Free access for students of MFF UK, sign in with your university account, would require approval
- Microsoft 365 Copilot - Sign with your university account, e.g.,
xxxx@cuni.cz - Github Copilot - Need to sign to the students program to get free access and credits.
Credit Project
See Credit Information Page for details.
Each individual step of the project should be submitted as a separate merge-request.
Deadlines
- Schedule your individul deadlines for each phase of the projectand put it into Gitlab
README.mdfile.- Create a merge request with your schedule and assign it to
@faltintfor approval.
- Create a merge request with your schedule and assign it to
- Each step will require multiple iterations and feedback from the instructor. Therefore, it is important to schedule your deadlines accordingly and not leave them until the last minute.
Step 1:Project Proposal (e.g., 30.11. 23:59)
Do a quick research and propose a project idea.
Step 2: Technology demo - POC (e.g., 11.01. 23:59)
Demonstrate a working prototype of your project. The goal is to show that your project is feasible and that all the necessary technologies are available and can be integrated.
Create a merge-reguest in GitLab.
It must contain:
- A short description of the demo, e.g., what it does and how it works.
- Description of the required technologies and libraries that needs to be installed to run the demo, including their versions.
- A build script, e.g., a cmake/script. (Worst case, a detailed manual how to build and run the demo.)
Step 3: Final Project Submission (e.g., 31.05. 23:59)
TBD
Framework for Finding a Project Idea
Understanding & Curiosity
-
What system or concept do you want to deeply understand?
Examples: OS, compilers, networking, ML pipelines. -
Is there a technology you’ve always wondered about internally?
Examples: Blockchain, Docker, game engines.
Technology & Tools
- What libraries or frameworks does your domain rely on?
Examples: OpenMP, MPI, LLVM, TensorFlow. - Could you integrate multiple libraries for something new?
User-Centered Design
- Ask peers: What tasks frustrate them?
- Automate repetitive tasks or improve incomplete tools.
Innovation & Improvement
- Combine two ideas into something new.
- Implement a research algorithm practically.
- Create interactive learning tools.
Scalability & Performance
- Design for large data or parallel processing.
- Optimize for speed, memory, or energy.
Social Impact & Accessibility
- Improve accessibility for people with disabilities.
- Make complex tools easier for beginners.
IDEs
VS Code
Recommended extensions
-
C/C++ (
ms-vscode.cpptools) – debugger -
CMake Tools (
ms-vscode.cmake-tools) – configure, build, run -
clangd (
llvm-vs-code-extensions.vscode-clangd) – code completion and diagnostics- When asked, let it disable the IntelliSense of the C/C++ extension (the two conflict).
clangd – setting the C++ version
Create the file .clangd in the project root:
CompileFlags:
Add: [-std=c++23]
Then restart the clangd server: View → Command Palette (Ctrl+Shift+P) → clangd: Restart language server.
Tip: With CMake, you can instead add
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)toCMakeLists.txt. clangd then reads the exact compiler flags frombuild/compile_commands.jsonand.clangdis not needed.
CMake – setting up the project
Also works for Visual Studio in Folder mode. Create the file CMakeLists.txt in the project root:
cmake_minimum_required(VERSION 3.20)
project(labtest CXX)
add_executable(my_prog source.cpp)
set_property(TARGET my_prog PROPERTY CXX_STANDARD 23)
set_property(TARGET my_prog PROPERTY CXX_STANDARD_REQUIRED ON)
In VS Code: Command Palette → CMake: Select a Kit (choose your compiler) → CMake: Configure. Then build with CMake: Build (F7) or the Build button in the bottom status bar.
Debugging – program and arguments
Run → Add Configuration…, choose the template below and edit .vscode/launch.json.
Windows (MSVC) – template C/C++: (Windows) Launch:
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Debug/my_prog.exe",
"args": ["expr1.txt", "input1.csv", "output1.csv"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal"
}
]
}
Linux (GCC + gdb) – template C/C++: (gdb) Launch:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/my_prog",
"args": ["expr1.txt", "input1.csv", "output1.csv"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
Tip: Instead of hard-coding
program, you can use"${command:cmake.launchTargetPath}"– CMake Tools then fills in the path of the selected target (works on both Windows and Linux).
Visual Studio
Project mode (.sln)
Project → Properties → Configuration Properties → Debugging, set Command Arguments. Make sure Working Directory is $(ProjectDir).
Folder mode (CMake)
Use the CMakeLists.txt from above. Then Debug → Debug and Launch Settings for my_prog and edit launch.vs.json:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "my_prog.exe",
"name": "my_prog.exe",
"currentDir": "${projectDir}",
"args": ["expr1.txt", "input1.csv", "output1.csv"]
}
]
}