Perform the following steps to try the recipe:
- From a new Terminal, run the following to download the source code:
> cd ~/
> git clone https://github.com/PacktPublishing/Advanced-CPP-CookBook.git
> cd Advanced-CPP-CookBook/chapter02
- To compile the source code, run the following:
> mkdir build && cd build
> cmake ..
> make recipe04_examples
- Once the source code is compiled, you can execute each example in this recipe by running the following commands:
> ./recipe04_example01
terminate called after throwing an instance of 'std::runtime_error'
what(): 42
Aborted
> ./recipe04_example02
The answer is: 42
> ./recipe04_example03
terminate called after throwing an instance of 'std::runtime_error'
what(): 42
Aborted
> ./recipe04_example04
# exceptions: 2
The answer is: 42
The answer is: always 42
In the next section, we will step through each of these examples and explain what each example program does and how it relates to the lessons being taught in this recipe.