<p>How are assertions done in c++? Example code is appreciated.</p>

Assertion are boolean expressions which should typically always be true.
They are used to ensure what you expected is also what happens.
```
```
void some_function(int age)
{
     assert(age > 0);
}
```
```
You wrote the function to deal with ages, you also 'know' for sure you're always passing sensible arguments, then you use an assert. It's like saying "I know this can never go wrong, but if it does, I want to know", because, well, everyone makes mistakes.
So it's not to check for sensible user input, if there are scenario's where something can go wrong, don't use an assert. Do real checks and deal with the errors.
Asserts are typically only for debug builds, so don't put code with side effects in asserts.