book
Concepts of C++ Programming
Overview and Hello World
Goals:
Write good and modern C++ code.
Apply widely relevant C++ constructs.
Understand some advanced language concepts.
Non-Goals:
Become experts in C++.
Fancy language features.
Apply involved optimizations.
Prerequisites
Knowledge of imperative and object-oriented programming languages like Java.
Knowledge in data structures and algorithms.
Helpful: basics of operating systems and computer architecture.
Lecture Organization
Lecture: Mon 14:30 – 17:00, MW 0001
Lecturer: Dr. Alexis Engelke
Communication through Tweedback during lecture.
Exercises: Tue 14:15 – 15:45, Interims II HS 3
Material: Available online.
Exam: Written exam, 90 minutes on-site, open book (no external communication/AI tools).
Literature
Primary:
C++ Reference Documentation: https://en.cppreference.com/.
Lippman, C++ Primer.
Stroustrup, C++ Programming Language.
Introduction to C++
What is C++?
Multi-paradigm general-purpose programming language including imperative, object-oriented, generic, and functional programming.
Key Characteristics:
Compiled, statically typed, features for low-level programming.
History:
Developed by Bjarne Stroustrup at Bell Labs, originated as "C with classes."
First standardized in 1998 (C++98), with subsequent updates (C++03/11/14/17/20), now C++23.
C++ Standard vs. Implementations
Standard defines requirements for C++ implementations related to language features and libraries.
Various popular implementations include compilers such as Clang, GCC, and MSVC, with their own libraries like libstdc++ and libc++.
Reasons to Study C++
Performance:
Flexible abstraction and near-zero overhead.
System Scale:
Scales to large systems with discipline.
Interoperability:
Integrates well with C.
Significant legacy code base needs developers.
Insights on Learning C++
Learning C++ does not prohibit studying other languages. It remains important to learn a variety of programming languages.
Understanding that there is no such thing as "zero-cost abstraction" is critical.
Hello World Example
Basic structure of a C++ program demonstrated with a simple Hello World.
#include <print>
int main() {
std::println("Hello World!");
return 0;
}Program Arguments
maincan take parameters for command-line arguments.Example:
int main(int argc, char** argv).A segmentation fault can occur if out-of-bounds are accessed.
Debugging Techniques
Compile with debug information using
-g.Use GDB for debugging and identify crashes.
Compiler Flags
Important flags:
-std=c++23(sets the version).-Walland-Wextra(enable warnings).-O0(no optimization, good for debugging).
Build Systems: CMake
CMake is recommended for larger-scale projects to avoid error-prone management of compiler commands.
Example CMake configuration provided for a simple project setup.
Summary
Basic understanding of C++, organization of C++ programming concepts, importance of source management, debugging practices, compiler flags, and recommendations for the use of CMake for building C++ projects.