Learn Modern C++#
Introduction#
In this section, we will discuss and experiment with C++ programming. C++ is a high-level programming language that is used for general-purpose programming. It is a compiled language that is especially suited to systems programming and applications requiring high performance. C++ was developed by Bjarne Stroustrup in the 1980s as an extension of the C programming language. It has since been updated and improved, and is still widely used in systems programming, game development, and high-performance computing.
Table of Contents#
- Strings and Character Literals
- Variables, Scopes and Namespaces: Assign
- Variables, Scopes and Namespaces: Swap
- Variables, Scopes and Namespaces: Uniform Initialization
- Variables, Scopes and Namespaces: Scopes
- Variables, Scopes and Namespaces: Namespaces
- Variables, Scopes and Namespaces: Constants
- Variables, Scopes and Namespaces: References
- Variables, Scopes and Namespaces: Constexpr Variables
- Conditions and Operators: Conditions and Switch - Case
Resources and Textbooks Used#
“Learn Modern C++” br cpptutor (Online Course)#
The course maye be found here:
Learn Modern C++
Source code may be found in GitHib here:
Course source code
Dockerfile Used to Setup the C++23 Environment#
# Use Ubuntu 24.04 as the base image
FROM ubuntu:24.04 AS build
# Update package lists and install necessary tools
RUN apt update && apt install -y \
wget \
gnupg \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# Add the LLVM repository for Clang 18
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main" >> /etc/apt/sources.list \
&& apt update
# Install Clang 18
RUN apt install -y clang-18 lld-18 libc++-18-dev libc++abi-18-dev
# Set Clang 18 as the default compiler
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
# Set working directory
WORKDIR /app
# Copy your C++ source code into the container (optional)
COPY . .
# Start an interactive shell
CMD ["bash"]