Tips¶
Braces {} for initialization¶
You can define a variable in 2 formats:
The =
form is traditional and dates back to C, but if in doubt, use the general {}
-list forms. It saves you from a conversation that loses information.
Using {}
detects conversion and forces you to correct the mistakes. It is a good step to stop mistakes.
Single Quotes as digit separators¶
To make long literals more readable for humans, we can use a single quote (’) as a digit separator. For example, π is about
std::for_each¶
Guide: std::for_each
Syntax:
Another option is to use std::for_each().
It provides you with control over the indexes.