Modernes C++ Examples ⬆
![]() |
Directory grimm-examples\ contains ISO C++ code examples coming from Grimm's training website Modernes C++.It also includes build scripts (bash scripts, batch files, Make scripts) for experimenting with C++ on a Windows machine. |
The code examples presented below can be built/run with the following command line tools:
Build tool | Build file | Parent file | Environment(s) |
---|---|---|---|
cmd.exe |
build.bat |
Windows only | |
make.exe |
Makefile |
Makefile.inc |
Any a) |
sh.exe |
build.sh |
Any a) |
a) Here "Any" means "tested on Windows, Cygwin, MSYS2 and UNIX".<
Source file templateMethod.cpp
.
> build -verbose clean run Toolset: MSVC/MSBuild, Project: templateMethod Configuration: Release, Platform: x64 Generate configuration files into directory "build" Generate executable "templateMethod.exe" Execute "build\Release\templateMethod.exe" readData sortData writeData sortData
> make TOOLSET=clang clean run C:/opt/msys64/usr/bin/rm.exe -rf "build" "C:/opt/LLVM-15.0.6/bin/clang.exe" --std=c++17 -O2 -Wall -Wno-unused-variable -o build/Release/templateMethod.exe src/main/cpp/templateMethod.cpp build/Release/templateMethod.exe readData [.. (same output) ..]
visitor
Example ▴
This example has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | 00download.txt | build.bat | build.sh | CMakeLists.txt | Doxyfile | Makefile \---src \---main \---cpp visitor.cpp
Command build.bat
clean run
generates and executes the C++ program build\Release\visitor.exe
:
> build -verbose clean run Toolset: MSVC/MSBuild, Project: visitor Configuration: Release, Platform: x64 Generate configuration files into directory "build" Generate executable "visitor.exe" Execute "build\Release\visitor.exe" Visiting engine Visiting front left wheel Visiting front right wheel Visiting back left wheel Visiting back right wheel Visiting body Visiting engine Visiting car Starting my engine Kicking my front left wheel Kicking my front right wheel Kicking my back left wheel Kicking my back right wheel Moving my body Starting my engine Starting my car
> make TOOLSET=gcc clean run C:/opt/msys64/usr/bin/rm.exe -rf "build" "C:/opt/msys64/mingw64/bin/g++.exe" --std=c++17 -O2 -Wall -Wno-unused-variable -o build/Release/visitor.exe src/main/cpp/visitor.cpp build/Release/visitor.exe Visiting engine [.. (same output) ..]