Go through the following steps to try out 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/chapter08
- To compile the source code, run the following:
> 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
elements: 4 8 15 16 23 42
elements: 4 8 15 16 23 42
elements: 4 8 15 16 23 42
elements: 42
elements: 4 8 15 16 23 42
elements: 4 8 15 16 23 42
c1.at(0): 4
c1.front(): 4
c1.back(): 42
c1.data(): 0xc01eb0
c1.empty(): 0
c1.size(): 6
c1.max_size(): 2305843009213693951
c1.capacity(): 42
c1.capacity(): 6
c1.size(): 0
c1.size(): 42
c1.size(): 0
c1.size(): 42
elements: 4 8 15 16 23
==: 0
!=: 1
<: 1
<=: 1
>: 0
>=: 0
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.