How do you format code in Visual Studio Code (VSCode)?

The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F On Mac Shift + Option + F On Linux Ctrl + Shift + I Alternatively, you can find the shortcut, as well as other shortcuts, through the ‘Command Palette’ provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then searching for format document. For unsaved snippets Open command palette (Win: F1 or Ctrl+Shift+P) Find ‘Change Language … Read more

Iterate through a C++ Vector using a ‘for’ loop

Is there any reason I don’t see this in C++? Is it bad practice? No. It is not a bad practice, but the following approach renders your code certain flexibility. Usually, pre-C++11 the code for iterating over container elements uses iterators, something like: This is because it makes the code more flexible. All standard library containers … Read more

Iterate through a C++ Vector using a ‘for’ loop

Is there any reason I don’t see this in C++? Is it bad practice? No. It is not a bad practice, but the following approach renders your code certain flexibility. Usually, pre-C++11 the code for iterating over container elements uses iterators, something like: This is because it makes the code more flexible. All standard library … Read more

Iterate through a C++ Vector using a ‘for’ loop

Is there any reason I don’t see this in C++? Is it bad practice? No. It is not a bad practice, but the following approach renders your code certain flexibility. Usually, pre-C++11 the code for iterating over container elements uses iterators, something like: This is because it makes the code more flexible. All standard library … Read more